multithreading

How do I guarantee fast shutdown of my win32 app?

I've got a c++ Win32 app that has a number of threads that might be busy doing IO (HTTP calls, etc) when the user wants to shutdown the app. Currently, I play nicely and wait for all the threads to end before returning from main. Sometimes, this takes longer than I would like and indeed, it seems kind of pointless to make the user wait...

C# equivalent to java's wait and notify?

I am aware that you can lock an object in c# using lock but can you give up the lock and wait for something else to notify you that it's changed like you can in java with wait and notify? It seems to me that synchronised and lock in java and c# respectively are synonomous. ...

Does PHP have threading?

I found this PECL package called threads, but there is not a release yet. And nothing is coming up on the PHP website. ...

Suspending and notifying threads when there is work to do

I have multiple threads (C# application running on IIS) running that all need to communicate with the same MQ backend. To minimize network traffic, I need to only send a backend request when there is work to be done. There will be one thread to monitor if there is work to be done, and it needs to notify the other threads that they shou...

how do I wait on console input in c# for 15 seconds or so.

I need to ask for input in console and wait for few sec may be a min after that I need to default to some value. How can basically time our on console input in c# and proceed with default settings? If you have sample code that would be great. ...

WCF Service & Request queueing

Is using a handrolled POCO queue class using pseudo code T Dequeue() { lock(syncRoot) { if(queue.Empty) Thread.Wait(); } } void Enqueue(T item) { queue.Enqueue(item); Thread.Notify(); } for WCF request queueing a scalable approach? ...

Keyboard interruptable blocking queue in Python

Hi! It seems import Queue Queue.Queue().get(timeout=10) is keyboard interruptible (ctrl-c) whereas import Queue Queue.Queue().get() is not. I could always create a loop; import Queue q = Queue() while True: try: q.get(timeout=1000) except Queue.Empty: pass but this seems like a strange thing to do. S...

python threadsafe object cache

Hi, I have implemented a python webserver. Each http request spawns a new thread. I have a requirement of caching objects in memory and since its a webserver, I want the cache to be thread safe. Is there a standard implementatin of a thread safe object cache in python? I found the following http://freshmeat.net/projects/lrucache/ Thi...

Java BlockingQueue of Size=1?

Essentially what I want is a BlockingQueue of size=1. I have a "listener" thread that simply waits, blocking until an object is put into the queue, and then retrieves it--and a "producer" thread that actually puts the object into the queue. I can implement this with some synchronized blocks and a BlockingQueue implementation, but that s...

Deadlock in Java

Long time ago, I saved a sentence from a Java reference book: "Java has no mechanism to handle deadlock. it won't even know deadlock occurred." (Head First Java 2nd Edition, p.516) So, what is about it? Is there a way to catch deadlock case in Java? I mean, is there a way that our code understands a deadlock case occurred? ...

How does calling an updating UI thread from a Work thread works ?

If i have a function in a thread that is processing some data, then it calls a callback function to update the status in the UI. If the UI takes time to process the callback function then it is not so much usefull. Instead of just handling the update in the callback function, should it send some kind of message to the UI that way it doe...

How to avoid File Blocking

We are monitoring the progress of a customized app (whose source is not under our control) which writes to a XML Manifest. At times , the application is stuck due to unable to write into the Manifest file. Although we are covering our traces by explicitly closing the file handle using File.Close and also creating the file variables in Us...

What happens when an Apache worker starts its own worker thread or process?

If I'm using Apache with a pool of worker processes, and one of those launches its own long-running process, what happens to that worker? Will Apache kill it eventually, killing the child process? Will that worker be permanently unavailable, but keep running? How does it differ if it starts a thread instead of a process? How does it ...

I’m stunned: weird problem with python and sockets + threads

I have a python script that is a http-server: http://paste2.org/p/89701, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, but as soon as put the concurrency level in apache bench abov...

How to write a MSTest unit test that listens for an event to be raised from another thread?

I’m writing a test that expects to receive an event from an object that it is calling. Specifically, I am calling out to an object that connects to an AIX machine via SSH (using the open source Granados project), then disconnecting, and I want to make sure I receive the OnConnectionClosed event that is being raised during the disconnect....

"Thread was being aborted" exception whilst displaying dialog

In my app I've got a thread which displays for some time "please wait" dialog window, sometimes it is a very tiny amout of time and there is some glitch while drawing UI (I guess). I get the exception "Thread was being aborted" and completly have no idea how get rid of it. I mean Catch that exception in some way, or in some other way hi...

Share Symbian's RFile between two threads

Hi, in the multi-threaded app I am porting to Symbian using Open C, I have an object that uses an RFile to read/write data to file. This object is supposed to be accessed from different threads (it is threadsafe), however there is the issue that apparently RFile objects can only be accessed within one thread only. As soon as another thr...

How do you add tests for multi threaded support?

I have a Java service which now will execute in a batch mode. Multi threaded support is added to the service so for every batch request a thread pool will be dedicated to execute the batch. The question is how do I test this? I have functional tests that pass under the threaded version of the service but, somehow, I feel there must be an...

Calling performSelectorOnMainThread => Multithreaded app?

I noticed that the following banal call from my main thread [self performSelectorOnMainThread:@selector(rollBar:) withObject:nil waitUntilDone:false]; was causing [NSThread isMultiThreaded] to report that my app had become multithreaded. I thought that was only supposed to happen when you detach a thread, something that qu...

In Silverlight, how to invoke an operation on the Main Dispatch Thread?

In a WinForms UserControl, I would pass data to the main GUI thread by calling this.BeginInvoke() from any of the control's methods. What's the equivalent in a Silverlight UserControl? In other words, how can I take data provided by an arbitrary worker thread and ensure that it gets processed on the main displatch thread? ...