multithreading

Should I use PageAsyncTask or manual Threading within In ASP.NET MVC Controller for parallel operations

Hi everyone, I have an ASP.NET MVC application, and in one of the controllers I have two long-running operations. I want to execute them in parallel. At first, I simply rolled my own multithreading code by new'ing up a System.Threading.Thread() object, running it in the background, and thread.Join()ing it up before exiting the control...

How to properly do threading in C++?

I have a rather large, dynamic sparse matrix object class to write, and I want to make the following happen: one thread to handle placing elements into the matrix, and one to handle reading from the matrix. The only time when these two would conflict would be when they would both want to access the same row/column at the same time. As ...

How to get a second System.Thread.ThreadPool?

If I use the ThreadPool in a nested way, my application hangs: ThreadPool.QueueUserWorkItem((state) => ThreadPool.QueueUserWorkItem(Action)); How to get a second and independent ThreadPool to achieve nesting? ...

Correctly multithreaded quicksort or mergesort algo in Java?

Do you know of any library that would provide a well-tested concurrent quicksort or mergesort algorithm for Java? We've had issues on a 16-(virtual)-cores Mac where only one core (!) was working using the default Java sorting algo and it was, well, not good to see that very fine machine be completely underused. So we wrote our own (I w...

Alternative to Threads

I've read that threads are very problematic. What alternatives are available? Something that handles blocking and stuff automatically? A lot of people recommend the background worker, but I've no idea why. Anyone care to explain "easy" alternatives? The user will be able to select the number of threads to use (depending on their speed ...

Multiple threads slowing down overall dictionary access?

I am profiling a C# application and it looks like two threads each calling Dictionary<>.ContainsKey() 5000 time each on two separate but identical dictionaries (with only two items) is twice as slow as one thread calling Dictionary<>.ContainsKey() on a single dictionary 10000 times. I am measuring the "thread time" using a tool called ...

Thread limit in Unix before affecting performance

I have some questions regarding threads: What is the maximum number of threads allowed for a process before it decreases the performance of the application? If there's a limit, how can this be changed? Is there an ideal number of threads that should be running in a multi-threaded application? If it depends on what the application is do...

debugging thread in vs 2008 enterprise edition--c#

I don't know if the same question is asked before or no:- I have the question that how to debug multithreading in C#.net vs2008(enterprise edition) is there any special technique or tool???? See my application works fine with single thread but when there are two or more threads it behave abnormally...I know there is synchronization issu...

Using a QNetworkAccessManager.get, how can I decide to abort?

I am attempting to use the QT QNetworkAccessManager class to manage some downloads in a multi-threaded C++/QT application. On worker thread (edit: the thread is seperate for other reasons aside from doing the download), I'm would like to do a get to an external server and be ready to receive the results with the code: ... m_nam = new ...

Synchronous/Blocking Application.Invoke() for GTK#

Unfortunately, Application.Invoke() is asynchronous: private string ThreadFunction(int i) { string result = null; Gtk.Application.Invoke(delegate { OutputStringToUserInterface("i = " + i.ToString()); result = GetStringFromUserInterface(); }); return result; } This means that in this example Thread...

What is Daemon thread in java

Can anybody tell me what daemon threads are in Java? ...

Will the GTK+ timeout callbacks be called in strict time order?

When I add many different timeouts (with each intervall==0) in a thread, which is not the main thread (where gtk_main() resides)... g_timeout_add(0, func, NULL); ... will then the different func() callbacks occur in the same order I called the corresponding g_timeout_add()'s? The reason I'm asking is because GTK# is using internally...

Is a lock (threading) atomic?

This may sound like a stupid question, but if one locks a resource in a multi-threaded app, then the operation that happens on the resource, is that done atomically? I.E.: can the processor be interrupted or can a context switch occur while that resource has a lock on it? If it does, then nothing else can access this resource until it'...

How to get return value when BeginInvoke/Invoke is called in C#

I've this little method which is supposed to be thread safe. Everything works till i want it to have return value instead of void. How do i get the return value when BeginInvoke is called? public static string readControlText(Control varControl) { if (varControl.InvokeRequired) { varControl.BeginInvoke(new MethodI...

Which amount of code execution should I parallelize?

If I want to parallelize the execution of an algorithm what are the smalls chunks of code that I should split? A classic example is a sorting algorithm. For what element size or typical execution time does it make sense to split the sorting between multiple threads? Or when is the overhead for waiting on another thread larger than the e...

Can competing atomic operations starve one another?

Imagine a program with two threads. They are running the following code (CAS refers to Compare and Swap): // Visible to both threads static int test; // Run by thread A void foo() { // Check if value is 'test' and swap in 0xdeadbeef while(!CAS(&test, test, 0xdeadbeef)) {} } // Run by thread B void bar() { while(1) { ...

best approach for multithreaded server on .net?

Hi , I want to develop a server which will listen on some specific ports to receive requests from device.While processing a request following steps are followed. Read data from socket stream(sent from device) Parse byte data in to business objects Use business objects process request using database through ado.net layer Send response i...

How can I most effectively take advantage of multiple cores for short computations in .NET?

Here is the context: I am writing an interpreter in C# for a small programming language called Heron, and it has some primitive list operations which can be executed in parallel. One of the biggest challenges I am facing is to distribute the work done by the evaluator across the different cores effectively whenever a parallelizable ope...

Is Communicating Sequential Processes ever used in large multi threaded C++ programs?

I'm currently writing a large multi threaded C++ program (> 50K LOC). As such I've been motivated to read up alot on various techniques for handling multi-threaded code. One theory I've found to be quite cool is: http://en.wikipedia.org/wiki/Communicating_sequential_processes And it's invented by a slightly famous guy, who's made othe...

Synchronization help in Java

Hello, looking at http://download.eclipse.org/jetty/stable-7/xref/com/acme/ChatServlet.html, I don't seem to understand why there needs to be a synchronization block in a synchronized method, like so: private synchronized void chat(HttpServletRequest request,HttpServletResponse response,String username,String message) throws IOException...