multithreading

The best way to monitor output of process along with its execution

I have started a process in my Java code, this process take a very long time to run and could generate some output from time to time. I need to react to every output when they are generated, what is the best way to do this? ...

Using mutexes in multithreaded VB6

I'm updating legacy code, written in VB6, and I've come across the need for a mutex. I have two sockets, and I need to send and receive from various sources. So I plan on having one socket continuously listening for incoming connections, then the other is used to send or receive. A timer checks twenty times a second if a connection has ...

C++ OpenMP variable visibility in parallel tasks

Don't understand, where do I get this wrong. If compiled without openmp support, the code works correctly. But with openmp variables seem to get wrong visibility. I had the following intention. Each thread has its own max_private in which it finds the local maximum. Then a global maximum is found in a critical section. #include <iostre...

Make parent thread wait till child thread completes or timeout

I am running a Java process on unix. I need to run an external process which is spawned by the main process using ProcessBuilder. The main process waits until the external process is done, and then spawnes the next external process. I have got it working till here. public static void main(String[] args) { for(...) { int ...

Console ThreadPool not Executing

I'm struggling to understand why nothing is output using the following: class Program { static int m_Active = 500; static void Main(string[] args) { ThreadPool.SetMaxThreads(5, 5); Enumerable.Range(1, m_Active).ToList<int>() .ForEach(i => ThreadPool.QueueUserWorkItem((o) => { DoWork(i); })); }...

Get ip adresses on a lan with backgroundworker control

I want to get alive or dead ip addresses from a big lan. but it takes so many times. I decided to use backgroundworker here is my code: try { this.Status.Text = "Collecting Information..."; if(this.TxtWorkGroup.Text.Trim() == "") { MessageBox.Show("The Work Group name Should Not be Empty"); return; } ...

How to run a function on a background thread for Windows Phone 7?

Hi All, I'm using MVVM Light to build a WP7 (Windows Phone 7) application. I wish to have all the work performed by the Model to be run on a background thread. Then, when the work is done, raise an event so that the ViewModel can process the data. I have already found out that I cannot invoke a Delegate asynchronously from an WP7 app....

Java: How to get thread id from a thread pool?

I have a fixed thread pool that I submit tasks to (limited to 5 threads). How can I find out which one of those 5 threads executes my task (something like "thread #3 of 5 is doing this task")? ExecutorService taskExecutor = Executors.newFixedThreadPool(5); //in infinite loop: taskExecutor.execute(new MyTask()); .... private class MyTa...

Threads with Spring, wait, notify?

Hi All, I haven't used any of Spring's threading support before. Does it support any high level concept of the Thread class's wait and notify? ...

How to do this (PHP) in python or ruby?

My app takes a loooong list of urls, and split it in X (where X = $threads) so then I can start a thread.php and calculate the urls for it. Then it does GET and POST request to retrieve data I am using this: for($x=1;$x<=$threads;$x++){ $pid[] = exec("/path/bin/php thread.php <options> > /dev/null & echo \$!"); } For "threading"...

Cocoa Run Loop Input Sources

I am writing an iPhone application, and I need to download files in the background. I can handle the download files part, but I am not so sure about the background part. My current idea is to use a run loop to wait until the user selects a file to download. This appears to work, but a run loop exits if no input source is set. However...

Why does an autoreleased NSTask block the runloop on an NSOperation thread indefinitely?

I've run into an while trying to launch an NSTask from inside an NSOperation. Here's a very simple app I've put together to showcase the problem. When you click the button, an NSOperation is queued. It sets up an NSRunLoop, and calls a method which invokes an NSTask. The task is really simple- it just launches /bin/sleep for two seconds...

Is this thread/background worker design for a C# WPF application OK?

Being new to using threads etc in UI's, can I ask is the following simple design seem OK. Refer to diagram image at link here In particular: a) use of backgroundworker & backgroundworker ProgressChanged to have the aggregator work on a separate thread. So I would need a custom class/type that had all the data I'd need to pass back fro...

can a worker thread read a control in the GUI?

I got a thread running every few seconds fetching some data from a db but this is based on the selection on a listbox and on a few checkboxes... can I read the values of these controls without using the GUI thread? The data is also read whenever one of the controls change, but the data might change in db without warning...hence the thre...

how to check for BackgroundWorker.CancellationPending when my thread has called another?

How should I check for a CancellationPending within a BackgroundWorker DoWork method, when within this method I call off to a Pcap.Net packet capture routine, which responses via a callback. The two options I can think of is: a) write a loop at the bottom of the DoWork method to continually check for CancellationPending b) put the che...

Is my use of ConcurrentQueue here between 2 threads ok?

Hi, Is my use of ConcurrentQueue here between 2 threads ok? I wanted to check I don't need to "lock" anywhere explicitly. In particular look at the lines where I have in COMMENTS would I drop a packet here... public class PacketCapturer { private static ConcurrentQueue<Packet> _packetQueue = new ConcurrentQueue<Packet>(); public Pa...

Changing the value of jLabel in jDialog after loading it.

I've a JDialog with a JLabel. I want to change the value of label every 10 seconds. How can I redraw/repaint the JDialog with updated value in JLabel. ...

Python threading + socket IO lockup problem in Cygwin

I am having a weird concurrency issue with Python on Cygwin. I am running two threads: A thread which sends UDP packets at regular intervals A main thread which waits for KeyBoardInterrupt and when it receives one, it tells the UDP thread to stop sending via a boolean flag This works just fine under Linux (python 2.6) and Windows (Py...

The execution time of my threaded code does not benefit from threads with Join

I'm creating three threads in one of my application. The requirement I have is that the method that creates these three threads and starts them off should not return unless all these three threads are executed. I tried to use Join on all three threads. However, I observe that when I use Join the total execution time of my method is the ...

Changing CultureInfo of Main thread from worker thread

Is it possible to change CurrentUICulture of main thread when event is raised in worker thread? Code for ilustration: static void Main() { //do something Thread workerThread = new Thread(new ThreadStart(DoWork)); workerThread.Start(); //do something } void DoWork() { ConnectDatabase(); //do some work ChangeLangua...