multithreading

Difference between racearound condition and deadlock

What is the difference between a dead lock and a race around condition in programming terms? ...

Dynamic javascript injection without createElement

When running code in the context of a "thread" in the Google Gears API you do not have access to the "document" object and therefore createElement cannot be used to dynamically load a script. Does anyone have any ideas about how I might go about "injecting" code in such a scenario? The only method I can think of is using a webservice an...

killing a running thread in java?

Hi, How to kill a running thread in java ...

Is this safe across threads?

I have some code that looks like this: Thread 0: CMyOtherClass *m_myclass; CMyClass::SomeFunc(DWORD SomeParam) { m_myclass = new CMyOtherClass(SomeParam); } Thread 1: CMyClass::InsideSecondThread() { MySecondThreadFunc(*m_myclass); } CMyClass::MySecondThreadFunc(MyOtherClass& myclass) { // do something with myclass varia...

NSTimer and updating UI

Hi all, Ive been trying to get my game to work correctly with an NSTimer. Ive seen many people have had a similar problem to me and I just need a bit of clarification on something. Basically I have an NSTimer running on the main thread which is updating images which represent the time, but I also have a mapView. When the user pans the ...

C# Multithreaded Proxy Checker

Hey, so got a new problem... I'm writing a multithreaded proxychecker in c#. I'm using BackgroundWorkers to solve the multithreading problem. But i have problems coordinating and assigning the proxys left in queue to the runnning workers. It works most of the time but sometimes no result comes back so some proxys get 'lost' during th...

Multi-Threading on multi core architecture

When you have a situation where Thread A reads some global variable and Thread B writes to the same variable, now unless read/write is not atomic on a single core, you can do it without synchronizing, however what happens when running on a multi-core machine? ...

How to lock a method for a whole class using synchronized?

I know when you want to lock method to be executed by only one thread you declare it with synchronized keyword. What about classes, how to provide a lock on an entire class of objects when a thread is executing some code on an instance of that class? In other words, when a thread is executing a method on an object, no other thread sho...

Understanding the low-level mouse and keyboard hook (win32)

I'm trying to capture global mouse and keyboard input. LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { if (wParam == WM_RBUTTONDOWN) printf("right mouse down\n"); if (wParam == WM_RBUTTONUP) printf("right mouse up\n"); } return CallNextHookEx(0, nCode, wParam, lParam); } HHOOK ...

Inter-thread communication (worker threads)

Hi all, I've created two threads A & B using CreateThread windows API. I'm trying to send the data from thread A to B. I know I can use Event object and wait for the Event object in another using "WaitForSingleObject" method. What this event does all is just signal the thread. That's it! But how I can send a data. Also I don't want thr...

Threading a prime number finder in C++

How can I use threading to write a program that finds the prime numbers between 0 and 1001? ...

Threading on both Windows and Linux

I have seen tutorials on the internet for making multithreaded applications in C++ on Windows, and other tutorials for doing the same on Linux, but not for both at the same time. Are there functions that would work even if they were compiled on either Linux or Windows? ...

Android: Toast in a thread

How can I display Toast messages from a thread? ...

How to get the parent thread in WinDBG?

When I analyzed a crush dump file, I often got such errors: 0:025> kP Child-SP RetAddr Call Site 0000000005a4fc78 0000000077548638 ntdll!DbgBreakPoint(void) [d:\w7rtm\minkernel\ntos\rtl\amd64\debugstb.asm @ 51] 0000000005a4fc80 00000000774b39cb ntdll!DbgUiRemoteBreakin( void * Context = 0x0000000000000000)+0x38 [d:...

Managing thread and memory usage while working with a blocking process

I have a bunch of files (on the order of 10 per second) coming into a system (stored into a database). Each file contains an entry for somewhere between 1 and 500 devices. A given device will appear in multiple files (but not every file). This data eventually needs to be stored in another database, stored per-device. There are two differ...

Message-based multithreading or Thread Pool for a short and uncommon action?

I'm currently using Retlang for message-based multithreading in .NET, which is a great library. I've got no explicit locks anymore, every thread is doing its own business, managing its part of the application and communicating with other threads via messages. I now have to implement a feature of my application that could also have its o...

Best way to pipe data from one Inputput Stream to multiple Output Streams

A PipedInputStream/PipedOutputStream connection works great when the data only needs to be piped to one output, but if multiple output streams are connected to one input stream, the data becomes fragmented across the different outputs. My current solution involves having a threaded "reader" that reads data from an InputStream and then w...

How is a pipe reading with a size of 4 bytes into a 4 byte int returning more data?

Reading from a pipe: unsigned int sample_in = 0; //4 bytes - 32bits, right? unsigned int len = sizeof(sample_in); // = 4 in debugger while (len > 0) { if (0 == ReadFile(hRead, &sample_in, sizeof(sample_in), &bytesRead, ...

Is this Singleton implementation correct and thread-safe?

Is this singleton implementation correct and thread-safe? class Class { public static readonly Class Instance; static Class() { Instance = new Class(); } private Class() {} } ...

Is this a safe way to execute threads alternatively?

I would like to run code alternatively, so I could stop execution at any moment. Is this code safe? static class Program { static void Main() { var foo = new Foo(); //wait for interaction (this will be GUI app, so eg. btnNext_click) foo.Continue(); //wait again etc. foo.Continue(); ...