multithreading

NSOperationQueue not reusing thread on iPhone

I'm using iPhone SDK 3.1.2, and the following code shows the NSOperationQueue does not reuse the thread for each task. The code does not have any problems on Snow Leopard. - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewCon...

Debugging Monitor.Enter, Monitor.Exit. How?

Is there anyway to see what objects have had locks placed on them in the visual studio IDE? ...

Java about 100 parallel threads, memory management

Hey folks, I am writing an optimazation algorithm which creates about 100 threads. Currently, I start them all at one time (for-loop) and after that I tell every thread that it should join(). My problem is now that each thread uses to much memory so the heap space exception won't take long. I want some kind of scheduling but don't know...

VB.Net Threading

I am working on a process at the moment which iterates through files in a folder; its used as part of a data migration. Each iteration of a file takes about 8 seconds; I need to run it about 30000 times so 8s that is a bit of a problem. The actions in the function cant be multithreaded as it pulls apart the document and that needs to be ...

Threaded State Machines in Java

Is there a way of Holding a thread in a State waiting for changes? I mean wait tll something happend (change var, call method, etc..) perhaps it needs using Event Listeners, or synchronized objects/methods.. The usual aproach for statemachines like this statemachine example That uses a do{..}while(true) loop that could work for singl...

Is Thread.interrupt() evil?

A teammate made the following claim: "Thread.interrupt() is inherently broken, and should (almost) never be used". I am trying to understand why this is the case. Is it a known best practice never to use Thread.inerrupt()? Can you provide evidence why it is broken / buggie, and should not be used for writing robust multithreaded code? ...

How to implement a critical section in CUDA?

I'm trying to implement a critical section in CUDA using atomic instructions, but I ran into some trouble. I have created the test program to show the problem: #include <cuda_runtime.h> #include <cutil_inline.h> #include <stdio.h> __global__ void k_testLocking(unsigned int* locks, int n) { int id = threadIdx.x % n; while (atomi...

How to execute web request in its own thread?

Hi, I am creating an android application which has to execute web requests in the background and then handle the received data and modify the user interface according to the server response. The goal of posting requests and handling data in the background is to avoid the freezing of user interface. Currently however I notice that the u...

How to find the current state of a thread in the scheduler strucure in windows.

Hi all, I want to know the current state(SUSPENDED/READY/RUNNING/WAITING state ) of a thread which has been created by CreateThread() api. How can I find it out? My developement environment is Visual studio 2008 Expresss edition also language is C/C++ /renjith g ...

WIN32: Yielding execution to another (given) thread

I am looking for a way to yield the remainder of the thread execution's scheduled time slice to a different thread. There is a SwitchToThread function in WINAPI, but it doesn't let the caller specify the thread it wants to switch to. I browsed MSDN for quite some time and haven't found anything that would offer just that. For an operati...

how to use QueueUserWorkItem with ref/out state?

Is it possible to do: ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc), ref data); such that my ThreadProc could make the caller's data point to a different location than when the call was originated? If it is not possible, is there a way to implement such functionality with IntPtr or something? ...

Calling sleep on current thread stalls my main GUI

I have one class DataThread inherited from Thread. I am using two DataThread objects ReadThread and WriteThread. I have another thread where Main_GUI is running. Now when I press a button on main_GUI it calls a method x.method1() and then this method uses the WriteThread method WriteThread.sleepForReset(). In public void sleepForReset...

Basic Architecture and Lifecycle of Threads in C#/.net 3.5SP1

I want to write my first real MultiThreaded C# Application. While I used a BackgroundWorker before and know a thing or two about lock(object), I never used the Thread object, Monitor.Enter etc. and I'm completely lost where to start designing the Architecture. Essentially my program runs in the background. Every 5 Minutes, it checks a w...

How to communicate between a .NET EXE and COM EXE?

I have a .NET EXE and ATL COM EXE in Windows Mobile. I need to communicate between them. I.e my ATL EXE launches the .NET EXE. The .NET EXE should send a message to the ATL EXE that the processing is completed or exited. How can I do that? How to communicate between the two separate process? ...

Want to avoid one call to sempost for eight threads

Scenario is: nthreads = 8 for j=0 = nthreads pthread_created (thread_func) for 1=0 to 1000 { // Some work. for j=0 = nthreads sempost(mutex1) // thread_func() for j=0 = nthreads semwait(mutex2) // Some work. } thread_func() { w...

concurrent handling of java.nio.channels.Selector

hello, i'm working with java.nio.channels.Selector and i'd like to create a separate thread for each selectedKey that is ready for read/write/accept but i want to make sure that the same socket is never handled by two different threads simultaneously. what would be the best way to do it ? i was thinking to cancel each selectedKey before...

Why does Asp.Net become non-responsive from remote machines but continue to work locally?

We have an Asp.Net 2.0 web app that is running on IIS (I've tried 5.1 on XP and 6.0 on 2003 with same results) and it works briefly and then becomes non-responsive. The odd thing is that requests from the local server (using "localhost" or the ip) continue to work fine. But all page requests from other machines just time out. I don't...

Thead was being aborted error when using process.waitforexit()

I have code below that is getting called from a while loop so it's executing multiple times in a row. Sometimes, but not always, I end up getting a thread was being aborted error on the p.WaitforExit(). Does anyone have any insight into this? should I be calling p.Close() after p.WaitForExit? string outputFileName = Path.Combine(Path.G...

Linq Datacontext and "unit of work"

The buzword in Linq now days is "unit of work". as in "Only keep your datacontext in existence for one unit of work" then destroy it. Well I have a few questions about that. I am creating a fat client WPF application. So my data context needs to track the entire web of instantiated object available for the user on the current screen. ...

What is the correct way in C# to download a file from the Internet and write it on the fly?

Edit: This is done in the Compact Framework, I don't have access to WebClient therefore it has to be done with HttpWebRequests. I am creating a download manager application that will be able to have concurrent downloads (more than one download at once) and the ability to report the percentage completed and resume the downloads. This me...