multithreading

BOOST libraries in multithreading-aware mode

There is a possibility to compile BOOST libraries in the so-called thread-aware mode. If so you will see "...-mt..." appeared in the library name. I can't understand what it gives me and when do I need to use such mode? Does it give me any benefits? More than that I'm really confused by having BOOST Threads library compiled in NO-thre...

Fastest synchronisation

I have the following scenario: The program has a reader and a writer thread to a socket which is an external application. The reader and writer need to work in coordinated cycles. The writer sends a dynamic number of messages (x) to the socket and the reader needs to read the responses from the socket. The number of messages is over 5 to...

C# once the main thread sleep, all thread stopped

I have a class running the Producer-Consumer model like this: public class SyncEvents { public bool waiting; public SyncEvents() { waiting = true; } } public class Producer { private readonly Queue<Delegate> _queue; private SyncEvents _sync; private Ob...

Access outer variable from inner anonymous Runnable

The following example code (SSCCE) complains that local variable a must be final. public class Foo { final List<A> list = new ArrayList() {{ add(new A()); }}; void foo() { A a; Thread t = new Thread(new Runnable() { public void run() { a = list.get(0); // not good ! } ...

With Swing & Java, what is done by the "Swing-Shell" thread

Hi, with threads & swing, the event queue (event dispatch thread) is broadly presented & discussed. However, when examining the thread states with a Swing application, there's also a thread named Swing-Shell. With brief googling I couldn't find much details, mostly thread stack traces with bug reports etc. Can somebody describe shortl...

Sudden excessive memory usage

I have an issue where my application runs fine for hours but then suddenly increases memory usage (in a matter of minutes) until it crashes. If we minimize the application during the increasing memory usage, the memory goes way down and stays down for a while. This seems to happen very inconsistently. Any idea how to troubleshoot it/what...

C# Can I pass more than one data into my target method when using ThreadPool?

use ThreadPool.QueueUserWorkItem (WaitCallback, Object) to start a thread with my target method and data. Can I pass more than one data into my method? the second parameter in QueueUserWorkItem (WaitCallback, Object) can be an array? ...

Java Swing long Thread execution

Hi folks, I have written a framework that does calculations that take a long time to execute (about 15 minutes). I now want to write an interface in Swing which will gather the data from the database and execute this calculations. I just wondered now how to do that best practice? If I do time intensive computations in the event thread ...

ASP.NET CacheDependency out of ThreadPool

In an async http handler, we add items to the ASP.NET cache, with dependencies on some files. If the async method executes on a thread from the ThreadPool, all is fine: AsyncResult result = new AsyncResult(context, cb, extraData); ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result); But as soon as we try to execut...

Django with fastcgi and threads

I have a Django app, which spawns a thread to communicate with another server, using Pyro. Unfortunately, it seems like under fastcgi, multiple versions of this thread are fired off, and a dictionary that should be globally constant within my program, isn't. (Sometimes it has the values I expect, sometimes not) What's the best way to e...

Waiting on Mainthread while continuing processing on UI

When working with console applications, Console.Readline relinquishes processing to the UI from the Main thread and only continues when an event, such as the pressing of the enter button is fired. How do I replicate this functionality (With a Window form as the UI in this case) in windows form application? ...

WPF: System.InvalidOperationException and System.Reflection.TargetInvocationException occasionally happening.

When running my program, sometimes I get these exceptions, other times I don't. This is the flow of execution: User clicks a button in the Window1 class. Class collects inputs, backgroundWorker.RunWorkerAsync() is started. In the DoWork, App.doStuff() is called. Inside App.doStuff(), I create another thread to show a progressbar in a di...

Comparison of performance between Scala etc. and C/C++/Fortran?

Hi all, I wonder if there is any reliable comparison of performance between "modern" multithreading-specialized languages like e.g. scala and "classic" "lower-level" languages like C, C++, Fortran using parallel libs like MPI, Posix or even Open-MP. Any links and suggestions welcome. ...

Python Thread/Queue issue..

I'm creating a threaded python script that has a collection of files that is put into a queue and then an unknown amount of threads (default is 3) to start downloading. When each of the threads complete it updates the stdout with the queue status and a percentage. All the files are being downloaded but the status information is wrong o...

How to close a thread in Java?

I'm very new to Java, and I'm trying to modify an example of a socket server to power a flash-based game. To allow flash to connect to the server, I need to serve up a policy file. I've never coded a server application before, so I'm not too familiar with the things which need to happen. Anyway, I have made it so that it outputs the fi...

Are java app servers able to destroy threads? If yes, how?

Destroying threads is deprecated in Java (and not implemented according to javadoc), and interrupting it is only a suggestion which upon the thread is expected to quit, but might not do so. (Not to provide any way to kill a thread inside the J*VM* is a disturbing design, but my question is not design related.) How do Java application se...

Need help returning object in thread run method

I have a Java class that extends Thread, it basically looks like the following: public class HttpRequestDispatcher extends Thread { private String url; private String method; // GET or POST private byte[] postData; public HttpRequestDispatcher(String url, String method, byte[] postData) { this.url = url; ...

How to access a Runnable object by Thread?

Possible duplicate: need-help-returning-object-in-thread-run-method Hello. I have a class implementing runnable and I have a List, storing Threads instantiated with different objects of that class. How can I access properties of underlying objects given the thread object running them? Here is an example: public class SO { public s...

why is this backgroundworker code causing this error: Parameter count mismatch.

what is wrong with this code below? The conn_PageDeleted is coming from a background thread and i am trying to update a label every time i get a call back. I get an error stating Parameter count mismatch. Here is the code: private void cmdDeletePage_Click(object sender, EventArgs e) { worker = new BackgroundWorker(...

Instantiated components from within a thread aren't repainting into a JFrame in Java

Hi, I have a single class like this one public class BlockSpawner implements Runnable{ public static long timeToSpawn; private GtrisJFrame frame; public BlockSpawner(GtrisJFrame frame) { this.frame = frame; timeToSpawn = 2000; } public void run() { while(true) { try { Thread.sleep(timeToSp...