multithreading

kill a process started with popen

After opening a pipe to a process with popen, is there a way to kill the thread that is started? Using pclose is not what I want because that will wait for the thread to finish, but I need to kill it. ...

How to call a method async with some kind of priority?

I need to call a couple of methods asynchronously with different priorities. My first idea was to use the ThreadPool and change the priority of the Thread like this: static void Run() { ThreadPool.QueueUserWorkItem(new WaitCallback(SomeMethod)); } static void SomeMethod(object o) { Thread.CurrentThread.Priority = ThreadPriority.Be...

Ruby only creating 3 threads at a time

I am trying to run 500 clients that send some request to the server simultaneously for load testing purpose. The client is a ruby program again. Sounds trivial. But I am facing weird problem with ruby threads. My code looks like this - n = 10 n.times do Thread.new do `calc` end end The code is a sample. I'm just trying to ru...

Progress bar and multiple threads, decoupling GUI and logic - which design pattern would be the best?

Hello, I'm looking for a design pattern that would fit my application design. My application processes large amounts of data and produces some graphs. Data processing (fetching from files, CPU intensive calculations) and graph operations (drawing, updating) are done in seperate threads. Graph can be scrolled - in this case new data...

Thread code criticism

Here's some code that someone wants to use in a production app (not me, honest) - I'd like some independent feedback on it please. // In this example, the JobProcessor has only one thread in it. // It could be extensed to have multiple processors where each one has an // observer to work. public class JobProcessor<TJob> : IJobProces...

Lock free stack and queue in C#

Does anyone know if there are any lock-free container libraries available for .NET ? Preferably something that is proven to work and faster than the Synchronized wrappers we have in .NET. I have found some articles on the .NET, but none of them specify any speed benchmarking, nor do they inspire much confidence in their reliability. T...

Delay service at system startup.

I'm using VB 9. I want the only thread in my Windows Service (that is set to Automatic) to start its work 5 minutes after Windows starts. But if the user restarts the service manually, the thread should start working immediately when the service starts. How do I achieve this? ...

ASP.NET & AJAX threading

Referencing this question: http://stackoverflow.com/questions/435492/is-asp-net-multithreaded-how-does-it-execute-requests, would this be a correct interpretation of threading: ASP.NET has one worker process per application instance. It is multi-threaded, using its own application pool. The majority of threads are used for servicing...

Is Objective-C 2.0 exception handling supported on non Mac OS X platforms?

Objective-C 2.0 has some new enhancements: garbage collection fast enumeration: for..in properties thread synchronization: @synchronized(self) @try/@catch/@finally/@throw exception handling I'm interested in using Objective-C 2.0 as a language to program portable code across multiple operating system platforms - while avoiding framew...

Why is this code losing handles on Windows 7 Beta?

I'm looking for some random crashes in an old c++ application. Using sysinternals process explorer, I noticed the app losing handles, and extracted the exact situation, where the program is losing handles to a very short piece of code. DWORD WINAPI MyTestThread( void* PThread) { _endthreadex(0); return 0; } int WINAPI WinMain( HINST...

python exit a blocking thread?

in my code i loop though raw_input() to see if the user has requested to quit. My app can quit before the user quits, but my problem is the app is still alive until i enter a key to return from the blocking function raw_input(). Can i do to force raw_input() to return? by maybe sending it fake input? could i terminate the thread its on? ...

Mutual exclusion: is this safe?

Is this pattern for mutual exclusion as safe as I think it is? If so, what do you call it? lock (_lock) { if (_flag) return; else _flag = true; } try { //critical code... } finally { _flag = false; } I want to ensure the critical section, but without the other threads piling up waiting to acquire the lock. Obviously I ...

Thread.Interrupt() Question

TL;DR version: I have two threads. One of them might need to Interrupt() the other, but only if the other thread is in th middle of processing data that is related to the object that is affected by the first thread. How can I only Interrupt() the second thread based on certain conditions. I have been working on a program that spins up t...

Indy 10 IdTCPClient Reading Data using a separate thread?

Hi All, Question: What I'm looking for is the most typical or best practice way to use a separate thread to receive data using an IdTCPClient in Indy 10. Background: The below code is a sample of what I'm trying to do with the actual data processing parts removed for clarity. The Idea of the Thread is to receive all data (Variable siz...

iPhone use of mutexes with asynchronous URL requests

My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server with the following errors: *** Terminating app due to uncaught exception 'N...

Is there a worst case implementation of the JVM?

The Java memory model makes it clear what can and cannot be assumed about how threads interact through memory. For example, if one thread writes a new value to a field without appropriate synchronization then the new value is not guaranteed to be observable by other threads. In practice, however, other threads might anyhow read the new v...

Improving performance of C# code

How do I improve the performance of the following situation? I have an application that accepts multiple connections across a network. The application is written in C# and accepts Socket connections. Every five minutes, the application needs to perform a function call that updates the application and reports information back to the sock...

How do I communicate between threads in JavaScript?

I created an XPCOM object in C++ for a FireFox extension. I'm using a worker thread to listen for an event and when it happens, I need to do stuff on the main thread. Obviously, I can't just sit and wait in JavaScript on the main thread because you need to be able to use the browser (my event happens very rarely). I tried doing this in t...

Thread communication theory

What is the common theory behind thread communication? I have some primitive idea about how it should work but something doesn't settle well with me. Is there a way of doing it with interrupts? ...

Joptionpane popup window

Hi,i'm reading data from serial port for that i've created one window.when i click connect button i'll get another window showing message as "connected" with ok option and at the same time data starts coming but it wont dump until i click ok button of the front window,i want data should dump without clicking the ok button of the front wi...