multithreading

ReaderWriterLock vs lock{}

Please explain what are the main differences and when should I use what. The focus on web multi-threaded applications. ...

Java thread creation overhead

Conventional wisdom tells us that high-volume enterprise java applications should use thread pooling in preference to spawning new worker threads. The use of java.util.concurrent makes this straightforward. There do exist situations, however, where thread pooling is not a good fit. The specific example which I am currently wrestling wit...

Interview Question on .NET Threading

Could you describe two methods of synchronizing multi-threaded write access performed on a class member? Please could any one help me what is this meant to do and what is the right answer. ...

Remove need for Invoke() by handling within threaded library.

Within a class library I'm writing I have a method allowing the library to go and do some stuff on a different thread which does something like: public void DoStuffAsync(AP p) { this.Running = true; this.Cancel = false; ParameterizedThreadStart threadStart = new ParameterizedThreadStart(DoStuff); ...

What are the "things to know" when diving into multi-threaded programming in C++

I'm currently working on a wireless networking application in C++ and it's coming to a point where I'm going to want to multi-thread pieces of software under one process, rather than have them all in separate processes. Theoretically, I understand multi-threading, but I've yet to dive in practically. What should every programmer know...

How to synchronize a static variable among threads running different instances of a class in java?

I know that using the synchronize keyword before a method brings synchronization to that object. That is, 2 threads running the same instance of the object will be synchronized. However, since the synchronization is at the object level, 2 threads running different instances of the object will not be synchronized. So, if we have a static ...

Object vs byte[0] as lock

I commented earlier on this question ("Why java.lang.Object is not abstract?") stating that I'd heard that using a byte[0] as a lock was slightly more efficient than using an java.lang.Object. I'm sure I've read this somewhere but I can't recall where: Does anyone know if this is actually true? I suspect it's due to the instantiation o...

Is good multithreaded design premature optimization?

While i like the intellectual challenge coming from the design of multicore systems i realize that most of them were just unnecessary premature optimization. But on the other hand usually all systems have some performance need and refactoring it later into multithreading safe operations is hard or even just economically not possible bec...

QMutex stuck in locked state

I have a function which is part of a class and in this function there is a mutex.lock at the beginning of the function and a mutex.unlock just before its return. Now I have encountered a situation where the mutex is stuck in the locked state. What could be doing this if this function is the only place where I use that mutex to lock and...

pthread_exit() and initial thread

When I use pthread_exit() in the initial thread, the initial thread switches in the terminated state. But I did not understand about the process. Can exist a running process with the initial thread in the termitated state? ...

.NET Remoting thread locking mechanism

Hello all, I'm having a pressing issue and I'm hoping you all can help me out. I will try my best to explain it as well as I can. I am augmenting a system that uses .NET remoting to allow for database calls from a thin client to a server that executes said calls. The server itself has the data access components installed on it, so it...

Can Someone Explain Threads to Me?

I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered "thread safe". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing b...

Having a threading issue with tesseract/tessnet2, works with one thread but not two?

Howdy, I'm attempting to use OCR to automate some of the QA process we have in place at work. A QA worker gets one terminal open per document scanner, and as work orders are scanned, they appear in the terminal, and information from this terminal is entered into a different tool to be added to a database, then the QA worker signals they ...

Java sockets with thread execution

Hello all, i have coded a socket listener that should listen on port 80 and 81 and when data arrive on these ports execute operations on these data. I want this listener to concurrently listen on both these ports and hav coded in the following way. import java.net.*; import java.io.*; import java.text.DateFormat; import jav...

Windows Forms - How to kick of a seperate thread and hold current thread

Hi, I have a windows app and an an dll(windows form) that im trying to open (ActivationCheck), im trying to pause the current thread open a new thread (ActivationCheck) wait for that form event to return true then continue the main thread. Could someone explain\show me what im doing wrong - thanks. static class Program { pr...

python threading/fork?

I'm making a python script that needs to do 3 things simultaneously. What is a good way to achieve this as do to what i've heard about the GIL i'm not so lean into using threads anymore. 2 of the things that the script needs to do will be heavily active, they will have lots of work to do and then i need to have the third thing reporting ...

Is this a valid pattern for raising events in C#?

Update: For the benefit of anyone reading this, since .NET 4, the lock is unnecessary due to changes in synchronization of auto-generated events, so I just use this now: public static void Raise<T>(this EventHandler<T> handler, object sender, T e) where T : EventArgs { if (handler != null) { handlerCopy(sender, e); }...

How does Timer in Python work, regarding mutlithreading?

If I call Timer(.1, some_function, [some_arguments]).start() multiple times, what exactly happens behind the scenes? The source of our problem is ... We have a method that's essentially: def move(target): force = calculateForce(target-getCurrentPosition()) if(force != 0) setForce(force) Timer(.1, moveCursor, [tx]).start() ...

Android AsyncTask context problem

I've been working with AsyncTasks in Android and I am dealing with a strange issue. Take a simple example, an Activity with one AsyncTask. The task on the background does not do anything spectacular, it just sleeps for 8 seconds. At the end of the AsyncTask in the onPostExecute() method I am just setting a button visibility status to V...

Multi-threading access to SubmitChanges() (LINQ to SQL)

I am using Visual Studio 2010 Beta 2. In Parallel.For loop I execute the same method with different parameter values. After execution processed data must be stored in the database. But I've got an exception hat says that I could not work with the same data context from different threads. So the question will be how to work with dat...