multithreading

Java threads for the beginner

I've been trying to explain Java threading to a colleague who has never been exposed to multi-threaded applications, but apparently I'm not a very good teacher. Can anyone recommend a good online or offline resource that can explain threading in a simple, step-by-step manner? I know it's a complex topic, but surely there exists an arti...

500 Worker Threads, what kind of thread pool?

I am wondering if this is the best way to do this. I have about 500 threads that run indefinitely, but Thread.sleep for a minute when done one cycle of processing. ExecutorService es = Executors.newFixedThreadPool(list.size()+1); for (int i = 0; i < list.size(); i++) { es.execute(coreAppVector.elementAt(i)); //coreAppVector ...

Windows Threading: beginthread or QueueUserWorkItem (C++)

Hi Folks, I am wondering whether to use beginthread or QueueUserWorkItem for threaded methods in C++. What are the differences between the two APIs and in what context are they better suited? Thanks, BTW, I have read this question http://stackoverflow.com/questions/331536/windows-threading-beginthread-vs-beginthreadex-vs-createthread...

Best way: to implement an interrupt/cancel feature for all your threaded workers.

Hello there, So my question is how to implement cancel/interrupt feature into all (I mean ALL) thread workers in your application in best and most elegant way? It's not important if it's an HttpWebRequest, IO operation or calculation. User should have an possibility to cancel every action/thread at any moment. ...

Are background threads a bad idea? Why?

So I've been told what I'm doing here is wrong, but I'm not sure why. I have a webpage that imports a CSV file with document numbers to perform an expensive operation on. I've put the expensive operation into a background thread to prevent it from blocking the application. Here's what I have in a nutshell. protected void ButtonUpload...

Progress Dialog in Android doesn't Show?

Okay.. I am doing something similar to the below: private void onCreate() { final ProgressDialog dialog = ProgressDialog.show(this, "Please wait..", "Doing stuff..", true); Thread t = new Thread() { public void run() { //do some serious stuff... dialog.dismiss(); } }; t.start(); t.join(); stepTwo(...

Execute another program in multi-threaded program

Hi, Just wondering how if it's possible to execute another program in a thread and send information to/get information from it. Essentially the same concept as with a child process and using pipes to communicate - however I don't want to use fork. I can't seem to find whether it's possible to do this, any help would be appreciated. Th...

How to Perform Continues Iteration over Shared Dictionary in Multi-threaded Environment

Dear Gurus. Note Pls do not tell me regarding alternative to custom session, Pls answer only relative to the Pattern Scenario I have Done Custom Session Management in my application(WCF Service) for this I have a Dictionary shared to all thread. When a specific function Gets called I add a New Session and Issue SessionId to the clien...

Is the Microsoft Enterprise Library Data Access Application Block thread safe?

I can't seem to find any documentation regarding thread safety... In particular - is the Database class (and subclasses) thread safe How would I find this out for myself? Are there references to thread safety for classes on the MSDN site? ...

msgsnd: Invalid argument

I receive msgsnd: Invalid argument error while using my program. Another thing i noted is that error do not occur if the file size is medium while it occurs when file size is slightly more. Is is due to memory overflow? If yes then what is the solution. Regards, Bhavin. ...

Occasional InterruptedException when quitting a Swing application

I recently updated my computer to a more powerful one, with a quad-core hyperthreading processor (i7), thus plenty of real concurrency available. Now I'm occasionally getting the following error when quitting (System.exit(0)) an application (with a Swing GUI) that I'm developing: Exception while removing reference: java.lang.Interrupted...

How to use Multiple Variables for a lock Scope in C#

I have a situation where a block of code should be executed only if two locker objects are free. I was hoping there would be something like: lock(a,b) { // this scope is in critical region } However, there seems to be nothing like that. So does it mean the only way for doing this is: lock(a) { lock(b) { // this...

Hibernate many-to-many mapping not saved in pivot table

I having problems saving many to many relationships to a pivot table. The way the pojos are created is unfortunately a pretty long process which spans over a couple of different threads which work on the (to this point un-saved) object until it is finally persisted. I associate the related objects to one another right after they are cre...

Can I safely bind to data on multi-threaded applications?

Hi everyone, I'm trying to solve a classic problem - I have a multi-threaded application which runs some processor-intensive calculations, with a GUI interface. Every time one of the threads has completed a task, I'd like to update a status on a table taskID | status I use DataGridView and BindingList in the following way: Bin...

Pass string between two threads in java

I have to search a string in a file and write the matched lines to another file. I have a thread to read a file and a thread to write a file. I want to send the stringBuffer from read thread to write thread. Please help me to pass this. I amm getting null value passed. write thread: class OutputThread extends Thread{ /************...

How long is the time frame between context switches on Windows?

Reading CLR via C# 2.0 (I dont have 3.0 with me at the moment) Is this still the case: If there is only one CPU in a computer, only one thread can run at any one time. Windows has to keep track of the thread objects, and every so often, Windows has to decide which thread to schedule next to go to the CPU. This is additional code that h...

Help with porting thread functionality: Win32 --> .Net

Hi, I am responsible for porting a class from legacy Win32 code to .Net and I have come across a threading model that I'm not sure how best to implement in .Net. Basically the Win32 has one worker thread, which calls WaitForMultipleObjects() and executes the particular piece of code when a particular object has been triggered. This has a...

Why this lock statement doesn't work ?

why this lock test doesn't work ? it's throwing an exception bellow Console.Write that collection was modified.... static List<string> staticVar = new List<string>(); static void Main(string[] args) { Action<IEnumerable<int>> assyncMethod = enumerator => { lock (staticVar) ...

Java: multi-threaded maps: how do the implementations compare?

I'm looking for a good hash map implementation. Specifically, one that's good for creating a large number of maps, most of them small. So memory is an issue. It should be thread-safe (though losing the odd put might be an OK compromise in return for better performance), and fast for both get and put. And I'd also like the moon on a stick...

Efficient implementation of threads in the given scenario

I've got a winforms application that is set up in the following manner: 2 buttons, a textbox, an class object MX with a collection K as its member, function X and another function, Y. Function X parses a large database and enumerates some of its data in collection K. Button 1 calls function X. Function Y walks through the above collect...