multithreading

Mutex not working in Vista

I have 2 processes running. Both are creating a named mutex with the code Mutex mut = new Mutex(false, "ABC"); then both the process use mut.WaitOne() and mut.ReleaseMutex() to access a shared database file, a number of times in different methods. This code runs without any problems on XP. On Vista, I just try to run one process (Pr...

Avoid reusing of the same fd number in a multithread socket application

I have an asynchronous application executing several threads doing operations over sockets where operations are scheduled and then executed asynchronously. I'm trying to avoid a situation when once scheduled a read operation over a socket, the socket gets closed and reopened(by possibly another peer in another operation), before the fir...

only one of multiple threads to execute a particular code path

I have multiple threads starting at the roughly the same time --- all executing the same code path. Each thread needs to write records to a table in a database. If the table doesn't exist it should be created. Obviously two or more threads could see the table as missing, and try to create it. What is the preferred approach to ensure ...

Firefox crashes when XPCOM function called from thread

I want to create a thread from XPCOM Component ... Here is a code for that nsresult rv = NS_OK; nsCOMPtr<Callback> obj = do_CreateInstance("@jscallback.p2psearch.com/f2f;1", &rv); NS_ENSURE_SUCCESS(rv, rv); char* str="Hello from C++"; obj->Status(str); _beginthread( (void(*)(void* ))&(P2P::test), 0,obj); return...

multithreading with java swing for a simple 2d animation

hello , my final goal for this application is to animate several items in the same JPanel at a different speed using a thread for each item.the first part is done however the items move at the same speed and i have no idea on how to fix this problem. package javagamestutos; import java.awt.Color; import java.awt.Graphics; import java...

How to debug a multithreaded application in C++ which is hung (deadlock)?

In java debugging a hung application is easy. You can take the memory dump of the application and use and use eclipse jvm dump analyser to see the status of the threads and where each threads were blocked? Does something like this exists for C++? ...

Control.Invoke never calls delegate

I'm working with the DevExpress XtraGrid control. I have a routine that goes thru and adds all the controls on the current form dynamically, and launches on a seperate thread the routine for a given control to initialize it to the value that will be displayed to the end-user. Some of the controls are displaying calculated values, and ta...

BackgroundWorker vs background Thread

I have a stylistic question about the choice of background thread implementation I should use on a windows form app. Currently I have a BackgroundWorker on a form that has an infinite (while(true)) loop. In this loop I use WaitHandle.WaitAny to keep the thread snoozing until something of interest happens. One of the event handles I wait ...

Concurrent Programming Book for Unix in C

I'm looking for good books on concurrent programming in C in the Unix environment. They need to cover classic concurrency, Unix multi-processing, and POSIX thread. Most of the books I have found are not for C or Unix. Keep in mind that I am not expecting one book to cover all of that though it would be great if such a book existed. The ...

How to make another thread sleep in Java

I have a class that extends Thread. This thread when running spends most of it's time sleeping, it will perform a check, if true perform a simple action, then sleep for 1/2 second and repeat. The class also has a public method that is called by other threads. If this is called I want the thread to sleep for longer if it is already sleep...

How to effectively timeout a COM method call from C# code

I have had to set a fixed time out for a particular COM method call from a service that we have (which is written in C#). Not having used the System.Threading namespace for anything other than Thread.Sleep, I have had a play and have come up with a working prototype: bool _comCallSuccessful = false; bool _timedOut = false; private void...

How can I execute certain commands on a separate thread?

What is the best solution to allow an object to execute methods on a thread? The object is the owner of the TThread and the thread contains only a TidHTTP (blocking socket) to post request and parse the response. Example : Object > Execute Request on the Thread Thread > Send request via idHTTP, wait for response, send the result to th...

Good blogs about multi-threaded development?

About a year ago I read the book "Java concurrency in practice" and I learned a lot from it. I was wondering if there are any blogs about multi-threaded development in Java, since many topics discussed in blogs are not covered in books. If this blog also contains techniques about testing thread-safety it would be great, but any blog abo...

What is easiest way to create multithreaded applications with C/C++?

What is the easiest way to create multithreaded applications with C/C++? ...

Threading from within a class with static and non-static methods

Let's say I have class classA { void someMethod() { Thread a = new Thread(threadMethod); Thread b = new Thread(threadMethod); a.Start(); b.Start(); a.Join(); b.Join(); } void threadMethod() { int a = 0; a++; Console.Writeline(a); } } class classB { void someMethod() ...

Parallelizing nested loops with dependencies

My question is about how best to structure my (C++) code to support parallelizing a time consuming computation. The pseudocode in question has the following structure: for a_1(y_1) in A_1 for a_2(y_2) in A_2(a_1) ... for a_n(y_n) in A_n(a_1, ..., a_{n-1}) y_n = f(a_1, ..., a_n) y_{n-1} = g_n(Y_n) ... ...

Notification when a thread is destroyed

Hi! Is there a way to get a notification that a thread no longer runs (has returned) in your application? I know this is possible in kernel mode (using PsSetCreateThreadNotifyRoutine), but is there a way to know this from user mode, using only Win32 API ? The problem is that I can't control the code in the thread, because my module i...

Legacy-C C++ incorporation

Hi all. I'm currently working on a performance critical application which incorporates legacy c code (a SPICE variant). The problem is as follows: The creators of the legacy c code apparently believed that the use of argument passing is one of the great evils of the modern age. Thus about 90% of all the variables were declared globa...

Custom threads?

How does one create custom threads to run in a Gtk application? Given this simplistic example: @w = Gtk::Window.new "testtest" @l = Gtk::Label.new "test" @w.add @l @w.show_all Gtk.main How could I run a thread like this? Thread.start { loop { puts 'thread running'; @l.text = Time.now.to_s; sleep 1 }} I got that timeout-based appro...

[C#] MyThread.Join() blocks the whole application. Why ?

Hi, I want to download a file from a FTP server in the other Thread. The problem is, this thread causes that my application is freezed. Here You have the code, what am I doing wrong? Any help will by grateful :) (Of course I want to stop looping until the thread 'ReadBytesThread' terminates.) I make a new thread: DownloadThread = n...