multithreading

Is this code thread-safe? How can I make it thread-safe? (C#)

I have a WCF service with a security class for getting some of the attributes of the calling user. However I'm quite bad when it comes to thread safety - to this point, I haven't needed to do much with it, and only have a rudimentary theoretical understanding of the problems of multi-threading. Given the following function: public clas...

Multithread database access (.NET)

Hi, I'm currently building an app that generates quotes. The total time to generate all quotes is about 10 secs, and at present provides an unacceptable user experience. What I want to do is multi-thread each quote so the user can see results as they come in. The problem is that the app I've inherited does a lot of bus logic on the d...

.NET Multithreading - Do I need to synchronise access to a variable of primitive type?

The scenario I have a class with a bool Enabled property, that is used by a loop on another thread to see whether it should stop or not. The idea is that a different thread can set that property to false and stop the other thread running cleanly. The question Should I bother to serialise access to that Enabled property using somethin...

_beginthreadex static member function

How do I create a thread routine of a static member function class Blah { static void WINAPI Start(); }; // .. // ... // .... hThread = (HANDLE)_beginthreadex(NULL, 0, CBlah::Start, NULL, NULL, NULL); This gives me the following error: ***error C2664: '_beginthreadex' : cannot convert parameter 3 from 'void (void)' to 'unsigne...

Modal MessageBox on another Process' Handle may lock-up target Process

If I show a MessageBox as modal of a window on another process, it works just fine as long as my program remains responding. If it is closed or terminated while the MessageBox is showing the windows that received the MessageBox will be locked (but still responding) and it will have to be finalized via Task Manager. Here is a sample code...

How can I signal a forked child to terminate in Perl?

How can I make the same variable shared between the forked process? Or do I need to write to a file in the parent then read the value saved to the file in the child once the file exists? $something never appears to get set in this so it just loops in the sleep my $something = -1; &doit(); sub doit { my $pid = fork(); if ($pid == 0) ...

Howto multithreaded jython scripts running from java?

I'm constructing a framework in Java that will listen for events and then process them in Jython. Different event types will be sent to different scripts. Since jython takes quite some time to compile the script when PythonInterpreter.exec() is called, I will have to pre-compile the scripts. I'm doing it the following way: // initiali...

C# Threading Mechanism

Let's say I have an exposed interface as such: interface IMyService { MyResult MyOperation(); } This operation is synchronous and returns a value. My implemented interface has to do the following: Call an asynchronous method Wait for event #1 Wait for event #2 This is due to a 3rd party COM object I am working with. This co...

Java: synchronized put() with a list of objects

I'm using a LinkedBlockingQueue to handle message objects from other threads. For example, I have something like this: LinkedBlockingQueue<Message> message_queue = new LinkedBlockingQueue<Message>(); public void run(){ while(true){ Message m = message_queue.take(); handle_message(m); } } When I add a new mess...

Reccomended thread layer to use for iPhone development?

I'm new to Objective C, and Mac development... It appears that I can use the Posix threads API in my app.. Is this the recommended way? Or is their some Apple API I should be using for mutexes, condition variables and threads instead? I should add that I'm developing for the iPhone. I'd like to add exactly what I'm trying to do. Basica...

Should Java Thread IDs always start at 0?

I am working on a mutual exclusion assignment, but when I started I noticed my application's thread ID's start at 9. It doesn't change when I compile and execute it again. Is there some problem I'm missing, or can Java Thread IDs start at an arbitrary number? This question is related. For those interested, here is a class from Herlih...

Determining deterministic thread execution of a Java program

I wrote a very simple toy program to complete the execution of a task inside a thread as per the timing requirements specified by a user. The code and the sample output is below. What happens is that everytime you run the code, the task completion times would be within a + delta range of the time specified by the user. For e.g if the use...

How can I hook an application's main thread message queue processing on Windows CE

I have a Windows CE application that is targeted at several (well two) different windows CE devices. The application is developed in Visual studio 2005 using C++ & MFC (no .NET). One of the devices signals system shutdown to running apps. by posting a custom message to the apps. main thread message queue using the PostThreadMessage() A...

what does happen if I call run() method myself?

in the main method if I write this: Thread aThread = new Thread(); aThread.run(); what will happen??? ...

What are the differences between these two ways of starting threads?

If I have a class that implements the Runnable interface, what are the differences between these statements in the main method? MyThread t1 = new MyThread(); t1.start(); and MyThread t2 = new MyThread(); new Thread(t2).start(); ...

How to synchronize(d) methods and modify objects' properties within a parent object?

I have two threads running from a controller class. The first thread receives SMS messages and should continue running as long as the program is in the started state. The other thread is used to calculate the units GPS location. The controller launches the SMS thread and waits from a text message. If a text message meets certain criteri...

Is there any relation between CPU and threads??

if yes,what is the relation? ...

Asynchronous methods in RubyCocoa

I understand that it isn't possible/sensible to use threads in RubyCocoa. However it is possible to use asynchronous Cocoa methods to avoid blocking user interface events. I've successfully used a method on NSURLConnection to send an HTTP request and receive the response without blocking the user interface. But I'm wondering what other ...

Using SwingWorker publish efficiently

I am using SwingWorker to query a server process for a large number of "result" objects on a background thread. As individual results arrive I want to publish them and display them on the GUI. My question is: Given that I will be receiving potentially thousands of results is it more efficient to call publish(V... chunks) for every N re...

What does light weight process mean?

Threads are light weight processes, what does it mean? ...