multithreading

Is it reasonable to call CloseHandle() on a thread before it terminates?

I'd like to just create a thread, then call CloseHandle immediately and let the thread die on its own so that I don't have to do extra clean-up work in the 'original' thread (not that cleanup is hard in itself, but it means a fair amount of extra book-keeping which I'd like to avoid). MSDN says that calling CloseHandle() on a thread doe...

How good is the linux kernel in the new Quad Core processors running multithreading application

Hello, Is there anyone here with experience in the linux thread scheduler running multithreading applications in the new Quad core processors?. If there is someone like that can you please write here your experience about how is the performance of the kernel managing the different threads, Have you experienced any thread starving or the...

Python Threads - Critical Section

What is the "critical section" of a thread (in Python)? A thread enters the critical section by calling the acquire() method, which can either be blocking or non-blocking. A thread exits the critical section, by calling the release() method. - Understanding Threading in Python, Linux Gazette Also, what is the purpose of ...

QNX Object oriented threads in c++

Hello, I want to create a parallel object oriented system in QNX using c++ and threads. How do I do this? I tried: pthread_t our_thread_id; pthread_create(&our_thread_id, NULL, &functionA ,NULL); with function A being a pointer to a function: void *functionA() { //do something } However this function only works in C and not C++. ...

Thread using 50-100% CPU usage : MSVCR80.dll!endthreadex

I have sql 2005 sp1, and have been noticing a lot of MSVCR80.dll!endthreadex threads using Process Explorer taking all of the CPU on the server and they never go away until you either kill it, or restart sql server? Does any one know any work around as in like how to end it or stop it coz this happens everyday. ...

Is this thread.abort() normal and safe?

I created a custom autocomplete control, when the user press a key it queries the database server (using Remoting) on another thread. When the user types very fast, the program must cancel the previously executing request/thread. I previously implemented it as AsyncCallback first, but i find it cumbersome, too many house rules to fol...

What's the best way of ensuring valid object lifespan when using Boost.Asio?

Hi all. Been playing a lot with Boost.Asio of late. I like the library a lot since it offers a fantastic way to squeeze performance out of today's multicore systems. A question I have asked myself a few times, and I thought worth throwing out there regards object lifespan / ownership when making async calls with Asio. The problem I'v...

Any satisfactory approaches to unit testing thread safety in Java?

I am looking at improving a package that I believe not to be threadsafe when its input is shared between multiple worker threads. According to TDD principles, I should write some tests that fail in the first instance, and these would certainly be useful in assessing the problem. I realise that this is not a simple thing to acheive, and...

Are single-threaded applications a dead technology?

I just bought a new, sub-US$1,000 laptop, one aimed squarely at the consumer, non-developer market and, looking over the specs, was surprised to find that it came standard with a dual-core processor. This led me to the question: with multicore machines becoming the norm, is it ever correct to write a single-threaded application anymore?...

"A reference to a volatile field will not be treated as volatile" implications

The following code using System.Threading; class Test { volatile int counter = 0; public void Increment() { Interlocked.Increment(ref counter); } } Raises the following compiler warning: "A reference to a volatile field will not be treated as volatile" Am I doing something wrong here to raise this warning? Why...

ProgressBar freezes when using multithreading

Hi, I have a ProgressBar that uses the marquee style when a report is being generated. The reason I am doing this is because the ReportViewer control I use takes some time to generate the report thus making the form unresponsive. I generate the report using a thread so the ProgressBar can show that the program is working. However, when ...

Multithread a unit test

In order to test concurrency issues, I want to call the same method on two different threads at exactly the same time using a unit test. In fact I probably want to call the same method on several threads at the same time. I'm using Microsoft's built in unit tester for VS2008. My thoughts are that I would lock an object and then synchro...

Is it advantageous to use threads in windows?

Some of the fellows in the office think that when they've added threads to their code that windows will assign these threads to run on different processors of a multi-core or multi-processor machine. Then when this doesn't happen everything gets blamed on the existence of these threads colliding with one another on said multi-core or m...

Running a Java Thread in intervals

I have a thread that needs to be executed every 10 seconds. This thread contains several calls (12 - 15) to a database on another server. Additionally, it also accesses around 3 files. Consequently, there will be quite a lot of IO and network overhead. What is the best strategy to perform the above? One way would be to use the sleep ...

Block without spinning in Java?

Certain methods in Java will block until they can do something, like ServerSocket.accept() and InputStream.read(), but how it does this is not easy for me to find. The closest thing I can think of is a while() loop with a Thread.sleep() each time through, but the longer the sleep period, the less responsive the blocking, and the shorter ...

How to wait for a thread to finish its work

I have a console application. A class (let's say Worker) does some work in a separate thread and throws an event when it finishes. But this never happens because the execution ends instantly. How can I wait for the thread to finish and handle the event after it throws? static void Main(string[] args) { Worker worker = new Worker(); ...

How to enumerate threads in .NET using the Name property?

Suppose I start two threads like this: // Start first thread Thread loaderThread1 = new Thread(loader.Load); loaderThread1.Name = "Rope"; loaderThread1.Start(); // Start second thread Thread loaderThread2 = new Thread(loader.Load); loaderThread2.Name = ...

Is it safe to assume that Spring MessageSource implementations are thread-safe?

Is it safe to assume that all implementations of org.springframework.context.MessageSource interface are thread-safe after initialization? I would expect that it's safe, but now I'm looking through Spring source code, and there's org.springframework.context.support.ReloadableResourceBundleMessageSource which reloads properties from time...

What is the best way to implement C#'s BackgroundWorker in Delphi?

I use C#'s BackgroundWorker object frequently to start a thread and perform a task. What's the easiest way to accomplish the same thing in Delphi? Here's some code in C#: private void button1_Click(object sender, EventArgs e) { BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += new DoWorkEventHandler(bg_DoWork); bg.RunWo...

Properly notifying all listeners of a system wide named manual reset event and then immediately resetting it

I have a system-wide manual reset event that I create by doing the following: EventWaitHandle notifyEvent = new EventWaitHandle(false, EventResetMode.ManualReset, notifyEventName, out createdEvent); Several processes create this event (e.g. it is shared amongst them). It is used for notifying when something gets updated. I'd like to ...