multithreading

Java: How to test methods that call System.exit()?

I've got a few methods that should call System.exit() on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since System.exit() terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I ...

Why does Microsoft Visual C# 2008 Express Edition debugger randomly exit?

I am writing a multi-threaded Windows application in Microsoft Visual C# 2008 Express Edition. Recently, the debugger has been acting strangely. While I am Stepping Over lines of code using the F10, sometimes it will interpret my Step Over (F10) command just like a Continue command (F5) and then the program will resume running and the ...

tb_event_death when single stepping in dbx

When I am single stepping through one thread of a multi threaded program, the debugger gets interrupted with: 0x(some hex ref) : tdb_event_death : ret dbx: thread has exited -- next aborted My guess is a thread somewhere in the program I am debugging has stopped, but it's not the one I'm debugging so I can't see why I have to res...

SharePoint and thread safety

I'm looking for articles, forum or blog posts dealing with SharePoint and thread safety? I'm quite sure there are some special aspects regarding thread safety that have to be considered when working with the SharePoint object model. Actually I didn't find many information about this, yet. So I'm looking forward to your answers. Bye...

How do I perform a Unit Test using threads?

Executive Summary: When assertion errors are thrown in the threads, the unit test doesn't die. This makes sense, since one thread shouldn't be allowed to crash another thread. The question is how do I either 1) make the whole test fail when the first of the helper threads crashes or 2) loop through and determine the state of each thread ...

glibc's '-lmcheck' option and multithreading.

We've been trying to hunt down some heap corruption issues in our multi-threaded C++ apps. As one technique, we tried add -lmcheck to the libraries line of the application. This is causing the app to crash out with apparent heap corruption in relatively short order. Our app does use both malloc/free and new/delete (as appropriate). On...

Threaded loading (waiting) screen

I'm looking for a generic method to implement a wait screen during long operations. I have used threading a few times before, but I have the feeling that I implemented it either very poorly, or with way too much hassle (and copy/pasting - the horror!). I want to keep this as generic and simple as possible, so I won't have to implement l...

How to identify the GC Finalizer thread?

I have a .NET (C#) multi-threaded application and I want to know if a certain method runs inside the Finalizer thread. I've tried using Thread.CurrentThread.Name but it doesn't work (returns null). Anyone knows how can I query the current thread to discover if it's the Finalizer thread? ...

C# Threading, set max to 2, avaliable 1?

I have a threading issue, I'm setting the ThreadPool.SetMaxThreads(maxThreads, System.Environment.ProcessorCount) to 10 for example. But when I check how many are avaliable ThreadPool.GetAvailableThreads() it tells me theres (maxThreads - 1) so 9 in the example, but then goes onto use 10 threads. Any ideas why this is? Duplicate of t...

C# Threading, GetAvailableThreads()

Hi I have a threading issue, I'm setting the ThreadPool.SetMaxThreads(maxThreads, System.Environment.ProcessorCount) to 10 for example. But when I check how many are avaliable ThreadPool.GetAvailableThreads() it tells me theres (maxThreads - 1) so 9 in the example, but then goes onto use 10 threads. Any ideas why this is? Thanks for...

.net: threading debug

What are some of the techniques available to debug multi threading issues in .net environment. ...

threadlocal variables in a servlet

Are the threadlocals variables global to all the requests made to the servlet that owns the variables? I am using resin for the server. Thanks for awnser. I think I can make my self more clear. The specific Case: I want to: initialize a static variable when the request starts the execution. be able to query the value of the vari...

To CurrentThread.Abort or not to CurrentThread.Abort...

I've seen a number of examples that have a thread procedure that looks like this. private void ThreadProc() { while (serviceStarted) { // do some work Thread.Sleep(new TimeSpan(0, 0, 5)); } Thread.CurrentThread.Abort(); } Is the Abort() really necessary at the end? ...

How do I get the current state of a thread (e.g. blocking, suspended, running, etc..) in win32?

I couldn't find a documented API that yields this information. A friend suggested I use NtQuerySystemInformation. After looking it up, the information is there (see SYSTEM_THREAD ) but it is undocumented, and not very elegant - I get the information for all threads in the system. Do you know of a more elegant, preferably documented API...

Generic ThreadPool in .NET

Here's a relatively common task for me, and, I think, for many a .NET programmer: I want to use the .NET ThreadPool for scheduling worker threads that need to process a given type of tasks. As a refresher, the signatures for the queueing method of the ThreadPool and its associated delegate are: public static bool QueueUserWorkItem ( ...

ASP.NET and long running background threads - how do they mix?

In a ASP.NET application that I am writing I need to use connections to a specific server (something like a DB but... different). The connections are quite expensive to establish (a few seconds, literally) so I'm trying to write a pool to improve scalability. Everything is pretty simple, up to one point - recycling old connections. Wit...

Is there any way to kill a Thread in Python?

Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.? ...

EventLog Intermittent Exception

Hi, I have an intermittent problem with some code that writes to a Windows Event Log, using C# and .Net's EventLog class. Basically, this code works day-to-day perfectly, but very occasionally, we start getting errors like this: "System.ArgumentException: Only the first eight characters of a custom log name are significant, and...

How will locking behave in .net?

abstract class Foo { private List<Object> container; private bool update; Foo Foo() { container = new List<object>(); update = false; } public abstract Bar CreateBar(); public void BeginUpdate() { if (!update) { Thread update_thread = new Thread(new ThreadStar...

MSXML XSL Transformation mutithreaded performance contention

I have a multithreaded server C++ program that uses MSXML6 and continuously parses XML messages, then applies a prepared XSLT transform to produce text. I am running this on a server with 4 CPUs. Each thread is completely independent and uses its own transform object. There is no sharing of any COM objects among the threads. This works ...