multithreading

How to generate distinct random numbers per distinct threads in .NET?

Dear ladies and sirs. I have to generate 19 bit random numbers. However, there is a constraint - two threads may not generate the same random number when running certain code. The simplest solution is lock the entire code. However, I would like to know if there is a non locking solution. I thought, I can incorporate ManagedThreadId wit...

Why use SyncLocks in .NET for simple operations when Interlocked class is available?

I've been doing simple multi-threading in VB.NET for a while, and have just gotten into my first large multi-threaded project. I've always done everything using the Synclock statement because I didn't think there was a better way. I just learned about the Interlocked Class - it makes it look as though all this: Private SomeInt as Integ...

Multiple threads or process with threads

Hi, this is for an assignment so I'm not looking for code. I have to simulate a game where each player has turns and needs to 'pay attention' to what's going on. So far, i know I'll need two threads for each player, one that will sleep until the player's turn and the other paying attention. My question is: Should I work each player as...

Why would delaying a thread response fix view corruption?

6 times out of 10 my very simple iPhone app is getting a corrupted display on launch or crashes randomly. But it behaves fine in the simulator. The display corruption looks like mis-colored fonts, out of place font text, wrong background colors, etc. I've found a strange work-around.. when my thread delays by 2 seconds before calling ...

How Dispatcher differs from the background thread ?

How Dispatcher concept in .NET 3.5 in WPF differs from the background thread in .NET 2.0 ? For example what will be difference between statements below: delegate.Invoke/BeginInvoke AND this.dispatcher.Invoke/BeginInvoke ...

What happens if two COM classes each without a threading model are implemented in one in-proc COM server?

Consider a situation. I have an in-proc COM server that contains two COM classes. Both classes are marked as "no threading model" in the registry - the "ThreadingModel" value is just absent. Both classes read/write the same set of global variable without any synchronization. As far as I know "no threading model" will enforce COM to disa...

How to pause a thread in java?

Consider the following code: while(true) { someFunction(); Thread.sleep(1000); } What I want is that, someFunction() be called once every 10 seconds. But this is not the case. It is being called every second. I tried Thread.wait(1000), but even that doesnt help. I removed of the while part, just kept the body, and at ...

What is the basic concept behind WaitHandle in C# .net threading ?

What is the basic concept behind WaitHandle in C# .net threading ? Whats is its use ? When to use it ? What is the use of WaitAll and WaitAny methods inside it ? ...

Scala Actors with Java interop to underlying COM libraries

I'm working on a JVM project which uses ESRI components (COM based, wrapped with JIntegra.) The client has requested the JAR files we produce work on the JVM and be accessible to Java code. I'd like to use Scala but I'm worried about how well the library will play with Scala's actors. Particularly I'm worried about the different mecha...

How can I call notify() in Java without blocking?

Are there a replacement for the follow Java code that will not block? I want only ping a possible waiting thread. I does not want change any on a possible thread that is already in the monitor. synchronized( monitor ) { monitor.notify(); } ...

Syncronization Exception

Hi I have two threads, one thread processes a queue and the other thread adds stuff into the queue. I want to put the queue processing thread to sleep when its finished processing the queue I want to have the 2nd thread tell it to wake up when it has added an item to the queue However these functions call System.Threading.Synchroniz...

threading problem (EXC_BAD_ACCESS)

Hi all, the following code crashes the application, and I don't know why. It crashes irregularly, that means that sometimes the imageview can be shown for example 30 times when a row is clicked, sometimes it chrashes the second time when I select a row. FYI: the activity indicator,the action sheet and the variable imageNr are defined g...

Exception calling remote SOAP call from thread

This is an extension / next step of this question I asked a few minutes ago. I've a Delphi application with a main form and a thread. Every X seconds the thread makes a web services request for a remote object. It then posts back to the main form which handles updating the UI with the new information. I was previously using a TTimer...

New to MVVM - Best practices for seperating Data processing thread and UI Thread?

Good day. I have started messing around with the MVVP pattern, and I am having some problems with UI responsiveness versus data processing. I have a program that tracks packages. Shipment and package entities are persisted in SQL database, and are displayed in a WPF view. Upon initial retrieval of the records, there is a noticeable p...

Why do threads spontaneously awake from wait()?

Hi, I was wondering why threads spontaneously awake from wait() in java. Is it a design decision? Is it a compromise? EDIT: (from Java Concurrency in Practice, p. 300) wait is even allowed to return "spuriously" - not in response to any thread calling notify. Further the authors state: this is like a toaster with a loose ...

Ruby Multithreading: making one thread wait for a signal from another

In Ruby, I want to have two threads running at the same time, and want the background thread to periodically signal the foreground thread. How do I get the foreground thread to block until the background thread says 'go'? I can think of a few ways to do it, but am after the most appropriate, idiomatic Ruby method. In code: loop do # b...

Dequeue an array in perl with thread::queue

I am trying to process data with a set of threads and enqueue it with another, currently the enqueueing and dequeueing process doesn't seem to be working Any thoughs?? sub process() { while (my @DataElement = $DataQueue->dequeue()) { print "\t".$DataElement[0]."\n"; } } I use the following to enqueue the data my @l;...

creating QT gui using a thread in c++?

I am trying to create this QT gui using a thread but no luck. Below is my code. Problem is gui never shows up. /*INCLUDES HERE... .... */ using namespace std; struct mainStruct { int s_argc; char ** s_argv; }; typedef struct mainStruct mas; void *guifunc(void * arg); int main(int argc, char * argv[]) { mas m;<br> m.s_argc =...

How does Java handle multithreading?

How does Java decide which core to assign a thread or a process? Is there any way to control that? to prevent two large threads from executing on the same core? Basically what I am asking is for further information on either how multi-threading works in Java, or how to control it within Java. ...

Proper way to Dispose of a BackGroundWorker

Would this be a proper way to dispose of a BackGroundWorker? I'm not sure if it is necesary to remove the events before calling .Dispose(). Also is calling .Dispose() inside the RunWorkerCompleted delegate ok to do? public void RunProcessAsync(DateTime dumpDate) { BackgroundWorker worker = new BackgroundWorker(); worker.RunWor...