Questions tagged [threadpool]

A thread pool is a method to reuse existing threads, rather than always creating new ones. They allow for pooling resources in given limits and automatically assigning tasks to open workers. Use this tag when you have questions about implementing a thread pool, or using an existing thread pool implementation.

In multi-threaded applications, handling the various threads is a complicated task. Thread pool functionality is targeted to make it easier to use a large number of threads efficiently.

Because thread creation is relatively expensive, reusing threads in a pool can increase a programs performance. It can also help make better use of the available hardware threads by limiting the total number of threads that are created.

The main goal when using a thread pool is to be able to dynamically schedule work to a given set of workers. However, the original thread does not need to keep track of the thread creation itself, but forwards the thread management to the thread pool implementation. The thread pool will create new workers if necessary and destroy unused ones.

References

Related tags

4676 questions
2
votes
5 answers

.NET Thread Pool - Unresponsive WinForms UI

Scenario I have a Windows Forms Application. Inside the main form there is a loop that iterates around 3000 times, Creating a new instance of a class on a new thread to perform some calculations. Bearing in mind that this setup uses a Thread Pool,…
Goober
  • 13,146
  • 50
  • 126
  • 195
2
votes
1 answer

using system.thread.threadpool in powershell

I am after a example of some code in powershell using the threadpool. my friends at google can not help me. Any example would be great. Donald
Donald
  • 471
  • 9
  • 18
2
votes
1 answer

Custom Python Thread Pool Synchrnoization

I'm trying to create a thread pool in python and thought all was well and good until I went to run some tests. In my tests I am recording the time it takes for n tasks to be completed with x threads. I then plotted this data to check whether or not…
masterwok
  • 4,868
  • 4
  • 34
  • 41
2
votes
1 answer

Task.WaitAll Method (Task[], Int32) doesn't release the thread when it is expired

Task.WaitAll Method (Task[], Int32) doesn't release the thread when it is expired. I'm using.net framework 4.0. I find that Task.WaitAll Method still occupy the thread when it's expired. I write below code to test it. static void Main(string[]…
roast_soul
  • 3,554
  • 7
  • 36
  • 73
2
votes
2 answers

What is the relation between number of thread and number of processor cores?

I am writing a server application that is thread pool based(IOCP). But I don't know how many threads are appropriate. Is the thread number associated with the number of processor cores?
Summer
  • 209
  • 2
  • 9
2
votes
0 answers

pthread_cond_wait is too slow, is that a better way?

I used a thread pool, the main thread continuous add tasks into a queue, and throw a pthread_cond_signal that indicate the queue is not empty to the work threads. Then the work threads read the queue and throw a pthread_cond_signal indicate the…
Spirit
  • 603
  • 2
  • 8
  • 16
2
votes
0 answers

system.threading.task, thread pool and the strange memory usage

recently i got confused with Task and Thread pool, given the follow codes: static void Main(string[] args) { while (true) { Thread.Sleep(1); Task t = new Task(run); t.Start(); } …
pinopino
  • 264
  • 2
  • 12
2
votes
1 answer

Different applications and Threadpool threads (or not)?

I tested different projects with this simple code : ( 2010 ,4.5.1) bool a, b; new Thread(() => { a = Thread.CurrentThread.IsThreadPoolThread; }).Start(); Task.Factory.StartNew(() => { b = Thread.CurrentThread.IsThreadPoolThread; }); I wanted to…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
2
votes
0 answers

How to implement CommonJ Work Manager with WebSphere?

I have never implemented CommonJ Work Manager with WebSphere. Infact, i am not even familiar with this term. We have one schedular running currently which runs after specific time interval, it creates a job and handles the job to the…
DineshM
  • 829
  • 1
  • 15
  • 24
2
votes
2 answers

Cancel function in a java ThreadPool - Detect specific runnable in the Pool and cancel it

I have a ThreadPool in my android application where I run a bunch of threads in different situation in it. public class ThreadPoolExecuter { private final ExecutorService mExecuter; private static final int nThreads = 5; private…
Ali
  • 9,800
  • 19
  • 72
  • 152
2
votes
2 answers

How to use the same thread pool batch by batch

I found a good implementation of boost based thread pool which is an improvement over this and this . it is very easy to understand and test. It looks like this: #include #include // the actual thread…
rahman
  • 4,820
  • 16
  • 52
  • 86
2
votes
1 answer

What is an elegant way for calling a custom close-method on each worker-thread in a Java threadpool?

say I'm using a ExecutorService ex = Executors.newFixedThreadPool(nrofthreads); spinning up some work and waiting when it's done. However I have same Threadlocal objects in the worker-threads which need to be closed when the batch is done.…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
2
votes
1 answer

How long a thread will be alive in java?

I create a thread using Thread t = new Thread(); t.start(); You start a thread using t.start(); Now how long the thread will be alive? To what state it will go after X (the answer of above question) seconds? Thread t = new…
Siva
  • 209
  • 3
  • 11
2
votes
2 answers

How to close a form (used from a background thread) in thread safe manner?

I have a form that shows a data grid. I also have a method running on a different thread that updates only the displayed cells of the grid. To do this, this method calls a function on the form that returns the displayed cells. The problem I have is…
Marc.O
  • 125
  • 1
  • 11
2
votes
2 answers

How does newCachedThreadPool reuse threads?

I want to ask for a little more detail to the same question posted by Zeller over a year ago... The javadoc says that the service returned by Executors.newCachedThreadPool reuses threads. How is this possible? I get how the queue structure is setup…
1 2 3
99
100