multithreading

Switching threads for MFC application cleanup

I'm trying to clean up specific memory objects created by a specific thread (hence only accessible to that thread). The only way for me to achieve that is to switch to that particular thread when freeing that memory block. This is how I allocated the specific memory context: This is what I attempted to do: I have originally added t...

If you unlock an already unlocked mutex, is the behavior undefined?

If you unlock an already unlocked mutex, is the behavior unsafe, safe, or undefined? The purpose of the question is related to the following code, where I don't know if it would be better to unlock the mutexes within the if block, or just outside the if block. // This chunk of code makes dual locking semi-autonomous. int c_lckd...

What is the best way to thread work in c#?

What's the best way to thread work (methods) in c#? For example: Let's say I have a form and want to load data from db. My form controls: - dataGridView (to show data from DB), - label (loading status) and - button (start loading). When I click the button my form is frozen until the task is done. Also the loading status does...

Is it possible to have more than 32 locks in ConcurrentHashMap

I read ConcurrentHashMap works better in multi threading than Hashtable due to having locks at bucket level rather than map wide lock. It is at max 32 locks possible per map. Want to know why 32 and why not more than 32 locks. ...

Volatile or synchronized for primitive type?

In java, assignment is atomic if the size of the variable is less that or equal to 32 bits but is not if more than 32 bits. What(volatile/synchronized) would be more efficient to use in case of double or long assignment. like, volatile double x = y; synchronized is not applicable with primitive argument. How do i use synchronized i...

How to properly multi-thread with Core Data?

Hi there, I'm having a lot of issues with trying to perform some core data operations in a threaded NSOperation. Currently, I have created a managed object context in my app delegate that is purely used on my threaded NSOperations. I setup a NSOperationQueue with a max concurrency of 1 so each action is performed serially. For each ope...

Question about Environment.ProcessorCount

I am curious as to what the .NET property Environment.ProcessorCount actually returns. Does it return the number of cores, the number of processors or both? If my computer had 2 processors, each with 4 cores, would Environment.ProcessorCount return 2, 4, or 8? ...

C# WaitCallBack - ThreadPool

What is the exact purpose of WaitCallback delegate ? WaitCallback callback = new WaitCallback(PrintMessage); ThreadPool.QueueUserWorkItem(callback,"Hello"); static void PrintMessage(object obj) { Console.WriteLine(obj); } Can i mean "Wait" in the "TheadPool" until thread is availabe.Once it is available execute the target? ...

Tools, tips, and tricks for monitoring multithreaded .NET applications

I'm embarking on a C# project where certain tasks will be divvied up and run on multiple threads. I'm looking for as many good tools as possible to help make sure I'm running as efficiently as possible. So I want to watch for things like resource (CPU) usage, blocking, deadlocks, threads that are waiting for work, and so on. I want to...

C# Threads -ThreadStart Delegate

The execution of the following code yields error :No overloads of ProcessPerson Matches ThreadStart. public class Test { static void Main() { Person p = new Person(); p.Id = "cs0001"; p.Name = "William"; Thread th = new Thread(new ThreadStart(ProcessPerson)); ...

C# -Threading - Execution Order

When I execute threads th1,th2 and th3.They are executing one after another.How do i change my code so that the execution order is not predictable .(Without using Random). public class Test { static void Main() { Person p = new Person(); p.Id = "cs0001"; p.Name = "William"; Thread th1 = new Thre...

C# Asynchronous operation

Acctually I have hardtime in understanding BeginInvoke() and EndInvoke() pair. class AsynchronousDemo { public delegate void DemoDelegate(); static void Main() { DemoDelegate d = PrintA; IAsyncResult AResult = d.BeginInvoke(Callback,null); d.EndInvoke(AResult); Console.ReadKey(true); }...

Java, Massive message processing with queue manager (trading)

Hello, I would like to design a simple application (without j2ee and jms) that can process massive amount of messages (like in trading systems) I have created a service that can receive messages and place them in a queue to so that the system won't stuck when overloaded. Then I created a service (QueueService) that wraps the queue an...

What is the most efficent way to implement concurrency in Python?

In a cluster environment using Python what is the least expensive way to develop a concurrent application or what is the pro / con of the various options? ...

My EventWaitHandle says "Access to the path is denied", but its not

Quick summary with what I now know I've got an EventWaitHandle that I created and then closed. When I try to re-create it with this ctor, an "Access to the path ... is denied" exception is thrown. This exception is rare, most of the times it just re-creates the EventWaitHandle just fine. With the answer posted below (by me), I'm able ...

Multithreaded (TThread) Delphi application will not terminate

I have written an application (using Delphi 2009) that allows a user to select a series of queries which can be run across a number of different systems. In order to allow queries to be run concurrently, each query is run in its own thread, using a TADOQuery object. This all works fine. The problem that I have is when I try to close the...

Java Thread won't pause on I/O operation

I was under the impression that in Java, a Thread will pause and give other threads a chance to do some work during blocking I/O operations ( like Socket.read() or DataGramsocket.receive() ). For some reason in my multi threaded network application, a call to receive() is causing all my other threads to starve ( the thread that called re...

Designing a multi-process spider in Python

I'm working on a multi-process spider in Python. It should start scraping one page for links and work from there. Specifically, the top-level page contains a list of categories, the second-level pages events in those categories, and the final, third-level pages participants in the events. I can't predict how many categories, events or pa...

Nhibernate, multithreading, and race condition

I am having a problem with a race condition when saving to the database asynchronously using NHibernate. First an insert to the database is done asynchronously where the unique id is auto-generated. Before this insert returns back to the main thread with now persisted object that has the unique database generated id, the object in upda...

How do I pass multiple heap arrays to a new thread?

Hello everyone, I'm trying to learn how create new threads and run them. I need to pass a few variables into the function that is run on the new thread but I can't find out how to actually pass anything to that new function/thread. I'm following http://www.devarticles.com/c/a/Cplusplus/Multithreading-in-C/1/ but it only goes through h...