multithreading

Stopping a thread in Win32/MFC

I was reading through some threading related code and found this piece of code: MyThread::start() { //Create a thread m_pThread = AfxBeginThread(/*some parameters*/) //Create a duplicate handle for the created thread m_hDuplicateHandle = DuplicateHandle(/* some more parameters*/) } MyThread::stop() { //Set some variables so ...

How to catch an exception thrown in a critical section?

I'm working on win 32 multithreading with c++. Scenario: I have a function used by multiple threads. This function as a critical sections (or any kind of construct that can lock a resource). In the critical section an exception is thrown. At this point I need to take care of unlocking the resource in the exception catch block. Is there ...

Are there any common Design patterns or common idioms that are important for C++ win32 multithreading programming?

One example could be: RAII - Resource Acquisition is Initialization used with critical sections Any others that are important, popular and you often use? ...

How do I send and receive an integer array from client to server in Java socket programming?

I'm having a problem sending a job (an integer array) from client to server in two different packages over a socket connection. Any ideas please? I can explain further if my question is not clear enough. ...

Background Worker Event Handling

I've been struggling with event handling in backgroundworker threads. All the documentation I've come across make me believe that when a DoWork event handler throws an exception that exception should be dealt with in the RunWorkerCompleted handler and that exception will be available in the Error property of the RunWorkerCompletedEvent...

Whats the best way to close a WCF thread?

I have an application which is taking ages to close. When I close the app, it tries to dispose a number of threads that do TCP scanning, WCF P2P attempts, and so on. The problem lies in a WCF thread that stalls on a method for about 17 seconds. IP2PAuthenticationService server; ChannelFactory<IP2PAuthenticationService> channelFactory; ...

Can there be more than one AWT event queue?

I've got a thread dump of an applet running on JVM 1.6.0_12 in Opera 9.64 Build 10487 - and it shows three event queues! As far as I know the Java Swing event handling is single threaded - did this change in any recent update? My problem is, that multiple event queues will tend to cause deadlocks since I've got some more locks than only...

C++: Cross thread exception handling problem with boost::exception

Basically, I've got a situation where one thread throws an exception which a different thread needs to handle. I'm trying to do this with boost exception, however somewhere along the line the exception loses its type and thus isn't caught by the catch blocks. Basically, thread B wants to do something, however for various reasons it mus...

Cancelling a (p)thread in a critical section

I have an application that runs multiple threads which are sometimes cancelled. These threads may call into another object that internally accesses a resources (socket). To prevent the resource to be accessed simultaneously, there is a critical section to get some order in the execution. Now, when cancelling the thread, it (sometimes) h...

Behavior of WaitForMultipleObjects when multiple handles signal at the same time.

Given: I fill up an array of handles with auto reset events and pass it off to WaitForMultipleObjects with bWaitAll = FALSE. From MSDN: “When bWaitAll is FALSE, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns t...

How to debug a weird threaded open fifo issue?

A web service is configured to expose some of its data when receiving a USR1 signal. The signal will be sent by a xinetd server when it receives a request from a remote client, e.g. nc myserver 50666. When the web server receives USR1 signal, it opens a dedicated fifo pipe, writes its data to the pipe, and then close the pipe. In the mea...

Please help me solve my W3C validation API timeout issue

I'm using the W3C validation service to check that the text I type into a TextBox is valid markup. It's almost working. But, under particular conditions my input results in an error and then endless timeout exceptions. I have to close an re-open the program to get it working again. Please glance over my code and help me to solve th...

Synchronizing on shared data structure

Consider code that involves multiple threads writing to a shared data structure. Now each of these threads write objects to the shared container that are essentially unique. Take the following (fictitious) example: class Logger { IDictionary<string, Log> logDictionary = new Dictionary<string, Log>(); // Method called by several o...

design of a Producer/Consumer app

I have a producer app that generates an index (stores it in some in-memory tree data structure). And a consumer app will use the index to search for partial matches. I don't want the consumer UI to have to block (e.g. via some progress bar) while the producer is indexing the data. Basically if the user wishes to use the partial index, i...

Simultaneous Or Sequential writes-- Does it matter in terms of speed?

Simultaneous Or Sequential write operation-- Does it matter in terms of speed? With multicore processor, does it make sense to parallelize all the file write operation using multi thread, just to get a boost of speed? Of course, all those write operations are independent. ...

Threading in .net

I have a simple example of a winforms application where i choose a directory in a directory chooser and click a button to loop through the directory and copy each file in the directory into another directory. i want to do the file copy on a background thread to avoid locking the GUI. i am looking for the simplest solution to: Create...

BackgroundWorker completed event - which thread?

Does the completed event of the BackgroundWorker control come back on the GUI thread or do i have to marshal that back. Also, does the progress event come back on the GUI thread or do i have to marshal that back? ...

In my application, why does readInt() always throw an EOFException?

(Forgive me because I do not write in Java very often.) I'm writing a client-side network application in Java and I'm having an interesting issue. Every call to readInt() throws an EOFException. The variable is of type DataInputStream (initialized as: DataInputStream din = new DataInputStream(new BufferedInputStream(sock.getInputStream(...

Delphi - Threading frameworks

I am looking for a Threading framework to use in my Delphi application. Currently I am evaluating ‘OmniThreadLibrary’ - so far it looks good and does everything I need. Is there any other ‘Threading framework’ for Delphi ? (I am using D2006 & D2009) ...

How do you kill a thread in Java?

How do you kill a thread in Java? ...