multithreading

Delphi thread that waits for data, processes it, then resumes waiting

I need to create a thread in Delphi with the following characteristics: Waits until the main thread adds data to a shared queue. Processes all the data in the queue, returning the results to main thread (for this last part I'll just send messages to the main window). Processing is time-consuming, so new data may be added to the queue w...

Wait for a detached thread to finish in C++

How can I wait for a detached thread to finish in C++? I don't care about an exit status, I just want to know whether or not the thread has finished. I'm trying to provide a synchronous wrapper around an asynchronous thirdarty tool. The problem is a weird race condition crash involving a callback. The progression is: I call the thi...

Apache worker MPM and Linux threads

Apache's worker MPM creates multiple threads per process, where each thread handles a request. As of 2.6, the Linux kernel uses Native POSIX Threading Library, which has a 1:1 threading model. Given this, I would expect to see 100 apache processes if there are 100 simultaneous requests being serviced (one request -> one thread -> one pr...

2 Questions about named pipes

Hi i have a couple of question about using named pipes. Firstly, when trying to setup a pipe server, i have noticed that if i use the code below.. at the end of the first client connect the server becomes unavailable UNLESS i wrap the whole thing in a while (true) block. Have i done this correct? or is each server only supposed to be ac...

Interacting with the UI thread from an Async callback method?

I have a method that is asynchronously called when System.Net.Sockets.NetworkStream.BeginRead completes. skDelegate = New AsyncCallback(AddressOf skDataReceived) skStream.BeginRead(skBuffer, 0, 100000, skDelegate, New Object) In that callback method, I need to interact with the UI thread. Sub skDataReceived(ByVal result As IAsyncRe...

Considerations for threading in web environment

Hello, I am getting started with ASP.NET web development and was wondering what the differences are when multi-threading a standard winforms application versus a web-based application written in asp.net that will run in IIS. Is there any difference and if so, what are the limitations (and conversely any positives) of threading a web appl...

is it possible to let the lock{} or similar structure lock on writes only?

well i mean i have several sections of code that use some variable i want to protect. but the idea is that several threads only read that variable. and only one threads is writing to it and it does that not that frequetly. i want to be able to let multiple threads do reading at the same time and only lock this varialbe when the the writi...

example of thread specific data in C

Does anybody know of (or can post) an example of the use of thread-specific data? I'm looking for something that's clearly explained and easy to understand. I've got a global char * variable that I'm wanting to share between a couple threads, and I'm thinking this is what the thread specific data mechanism in C is for, am I right? I'm a...

Multithreading on a file open copy and write

Hi, I am new at threads here is the question, I have 3 threads one of them calls a method that writes into a file via File.AppendAllText method, other thread duplicates the text in the same file, and the last thread reads the text from file and print on a label. When I start the threads at the same button click event it gives the error...

TCPlistener.BeginAcceptSocket - async question

Hi, Some time ago I have payed to a programmer for doing multithread server. In the meantime I have learned C# a bit and now I think I can see the slowndown problem - I was told by that guy that nothing is processed on the main thread (Form) so it cannot be frozen..but it is. But I think that altough BeginAcceptSocket is async operation,...

Should I kill a function running as a thread (.Net)

Hi, I've just started with C#. I'm running an object's function as a thread (new Thread(myFunc).Start()). Does the thread kill itself when the function is finished or must I manually get rid of it? If I must, what is the best way to do it (I may not know when it finishes etc)? Thanx! ...

After wait shoudln't thread be in blocking state rather than runnable state?

Hi, I am going through a java 6 book. A sample code snippet is given below from Threads chapter, where I need a clarification synchronized(a){ //The thread gets the lcok on 'a' a.wait(2000);// Thread releases the lock and waits for notify only for maximum of two seconds, then goes back to runnable state //The thread reacquires the lock...

Java Random Slowdowns on Mac OS cont'd

I asked this question a few weeks ago, but I'm still having the problem and I have some new hints. The original question is here: http://stackoverflow.com/questions/1651887/java-random-slowdowns-on-mac-os Basically, I have a java application that splits a job into independent pieces and runs them in separate threads. The threads have...

ThreadPool.QueueUserWorkItem completed event?

When a user clicks a button, I use the ThreadPool.QueueUserWorkItem to spawn a thread that kicks off a long running process. I would like to make a button visible when the thread is completed so that user can click on it. Is there a completed event in ThreadPool What am I trying to do? One of the pages has a button when clicked conne...

Loading image in thread with WPF

Hi ! I'm trying to make a listbox that display pictures from internet. The items are provided by binding itemsource to a model that contain the URL of the image and some other properties (title, desc, etc...). Unfortunately, the list is very slow to load because WPF is trying to download all pictures from the web before showing the lis...

C# problem with redirecting standard error

The main form in my application launches a new thread, and then opens another form, which serves as a progress window. The thread pipes some data between 2 console applications, and information from the StandardError is sent to the progress window. I use the DataReceivedEventHandler to read the standarderror asynchronously. If I let eve...

Iphone multithreading and AI

I have an ai loop that I would like to write for my iphone app. I am under the understanding that this loop will take along time to make calculations and block the main application. I want to put it in a different thread and run everything off events. For example I would have an event that would be called when the players turn started...

C# Multithreading -- Invoke without a Control

I am only somewhat familiar with multi-threading in that I've read about it but have never used it in practice. I have a project that uses a third party library that shares the status of an input device by raising events. The problem is, the way the library is written these events are raised from a different thread. My application doe...

GCC: Force a function call after every instruction (for multithreaded testing)?

Hi, I'm trying to test a rather threading-sensitive area in my program and was wondering if there's a way to force gcc to insert a call after every instruction it emits so that I can manually yield to a different thread? Thanks, Robert ...

What is the difference between Go's multithreading and pthread or Java Threads?

What is the difference between Go's multithreading approach and other approaches, such as pthread, boost::thread or Java Threads? ...