threadpool

Exception handling in ThreadPools

I have a ScheduledThreadPoolExecutor that seems to be eating Exceptions. I want my executor service to notify me if a submitted Runnable throws an exception. For example, I'd like the code below to at the very least print the IndexArrayOutOfBoundsException's stackTrace threadPool.scheduleAtFixedRate( new Runnable() { public void...

Does ThreadPoolExecutor spawns a new thread if a current thread sleeps

Hi, This question is a followup on this one. Essentially what I am doing is declaring a ThreadPoolExecutor with just one thread. I am overriding the beforeExecute() method to put a sleep so that each of my tasks are executed with some delay among themselves. This is basically to give away the CPU to other threads since my thread is ki...

Creating a thread pooling in c#

Hi, I have 300 threads which is executing one by one. I use join, so its one-by-one. I want to execute N threads at a time. Can anyone direct me to a link on creating a thread pool in c# (with N threads). My situation is at a time N threads will execute, the rest of the threads will wait. When one thread finishes execution, one waiting...

Creating Thousands of Threads Quickly and Executing Them Near Simultaneously

I have a C#.NET application that needs to inform anywhere from 4000 to 40,000 connected devices to perform a task all at once (or as close to simultaneous as possible). The application works well; however, I am not satisfied with the performance. In a perfect world, as soon as I send the command I would like to see all of the devices r...

Asynchronous File I/O using threads in C

I'm trying to understand how asynchronous file operations being emulated using threads. I've found next-to-nothing materials to read about the subject. Is it possible that: a process uses a thread to open a regular file (HDD). the parent gets the file descriptor from the thread, now it may close the thread. the parent uses the file de...

Is there a way to detect when a QT QRunnable object is done?

Is there a way to detect when a QT QRunnable object is done? (Other than manually creating some signalling event at the end of the run() method.) ...

Gracefully stop a Timer callback worker thread

I am using System.Threading.Timer in my Windows service and locking the callback method using Monitor.TryEnter, so it's non-reentrant. Inside the callback, I am looping over some database objects (Linq to SQL entities) and performing some IO tasks. On each iteration of the loop, I am changing some properties of entity to flag it as proce...

What has improved in .NET 4.0 Threadpooling?

I am reading a C# 4.0 book which gives the following default values for the maximum thread limit for the threadpool. 1023 in Framework 4.0 in a 32-bit environment 32768 in Framework 4.0 in a 64-bit environment 250 per core in Framework 3.5 25 per core in Framework 2.0 Can anyone tell me what might might have prompted such a vast incr...

Use ThreadPool for applicationwide logging?

As a followup on this question discussing the use of the ThreadPool vs a dedicated thread: When would you use a dedicated thread (with lowered priority) for applicationwide logging and when would you use the ThreadPool? ...

C++ Thread Pool

What is a good open source implementation of a thread pool for C++ to use in production code (something like boost)? Please provide either your own example code or a link to example code usage. ...

Close foreground thread gracefully on windows service stop

In my windows service I create one "parent" foreground thread that in turn spawns "child" threads using ThreadPool (which means they are background) to execute tasks. What is the best way to close foreground thread gracefully on windows service stop? Here is my current implementation (stripped out of task-specific logic): public parti...

how to using ThreadPool to run socket thread parallel ?

I'm new in network programming and want to create new socket thread base on a request. My thread send request via tcp/ip socket and waiting the response. How can i using threadpool to create and run threads parallel ? Can anyone show me the sample ? Thank ! ...

How to handle database operations using threadpool and entity framework?

Hi! I really need some code examples here... What I am trying to do: GetCollectionFromDatabase foreach item { resetEvents[i] = new ManualResetEvent(false); var makeRequest = new MakeRequest(resetEvents[i]); ThreadPool.QueueUserWorkItem(new WaitCallback(makeRequest.ThreadPoolCallback), i); } ...

Calling GetAvailableThreads for different thread pools

I've used the ThreadPool.GetAvailableThreads to monitor the thread usage in a web site, and written the results to a performance counter. To do this, I've had a thread running in the site that does the monitoring. I'd like to be able to monitor this without modifying sites' code. Is there a way I can write a console app that would be abl...

[CLR Threading]When a thread pool thread blocks, the thread pool creates additional threads

I see this in the book "CLR via C#" and I don't catch it. If there are still threads available in the thread pool, why does it create additional threads? ...