threadpool

JAVA - Cancel the ThreadPoolExecutor running tasks

What I need is a method similar to shutdownNow, but, be able to submit new tasks after that. My ThreadPoolExecutor will be accepting a random number of tasks during my program execution. ...

ThreadPool & Object lifetime

Hi, In an asp.net web application, there is a thread pool which is used to call a method. This method, uses an instance of EF ObjectContext to perform its operation. I am using Unity Framework which resolves an ObjectContext using the per-thread-lifetime manager. Does this guarantee that at the end of the method operation, the thread...

PerThreadLifetimeManager in Unity

Hi, In the Unity PerThreadLifetimeManager documentation, I read that: "This lifetime manager does not dispose the instances it holds". Ref.: http://msdn.microsoft.com/en-us/library/ff647854.aspx So, if I am using a ThreadPool, does it mean that objects resolved using Unity on a Thread of the ThreadPool will not get disposed at the end...

Actor pool in scala

I have a project that is actor-based and for one part of it I must use some actors that receive message after that one actor assigns to each request separately and each actor is responsible for doing its message request, so I need something like a thread pool for actors of my project, are there any features in Scala that is useful for my...

500 Worker Threads, what kind of thread pool?

I am wondering if this is the best way to do this. I have about 500 threads that run indefinitely, but Thread.sleep for a minute when done one cycle of processing. ExecutorService es = Executors.newFixedThreadPool(list.size()+1); for (int i = 0; i < list.size(); i++) { es.execute(coreAppVector.elementAt(i)); //coreAppVector ...

Help with porting thread functionality: Win32 --> .Net

Hi, I am responsible for porting a class from legacy Win32 code to .Net and I have come across a threading model that I'm not sure how best to implement in .Net. Basically the Win32 has one worker thread, which calls WaitForMultipleObjects() and executes the particular piece of code when a particular object has been triggered. This has a...

How to log correct context with Threadpool threads using log4net?

I am trying to find a way to log useful context from a bunch of threads. The problem is that a lot of code is dealt with on Events that are arriving via threadpool threads (as far as I can tell) so their names are not in relation to any context. The problem can be demonstrated with the following code: class Program { private static ...

Better time-out detection for synchronous operations

I need a way to perform some action synchronously which should complete in half a second, but might just hang around for minutes. If it times out I don't care about the result. Here's the I'm doing it right now using compiler-generated delegate.BeginInvoke: static void Main() { bool disposed = false; var wait = new ManualResetEv...

Restart agent thread-pool after calling shutdown-agents

If I call (shutdown-agents) from the REPL, and then later on try to use an agent later on, I get an exception saying the agent pool isn't available (of course!). The question is, how can the agent thread pool be re-started without having to re-launch the REPL and lose all of my state? Thanks! ...

Is ThreadPool appropriate for this threading scenario?

I have a scenario that I'm trying to turn into a more responsive UI by pre-fetching some sub-elements of the results before they're actually required by the user if possible. I'm unclear on how best to approach the threading, so I'm hoping someone can provide some advice. Scenario There is search form (.NET rich client) that enable the...

How to re-use a thread in Java ?

I am a building a console Sudoku Solver where the main objective is raw speed. I now have a ManagerThread that starts WorkerThreads to compute the neibhbors of each cell. So one WorkerThread is started for each cell right now. How can I re-use an existing thread that has completed its work? The Thread Pool Pattern seems to be the solut...

Add multiples Picturebox using ThreadPool

Hi! Im doing a Naval Battle for University. I decided to do it in C#. My board is 20 x 20 of mini (20x20) PictureBoxes. The problem is when I load the board I got a huuuge delay for draw all of them in the panel which contains them. So I thought to ThreadPool my method to escale the picuteres boxes creation and drawing fester. Is this ...

Spring - scheduling and pooling runnables of different state (each Runnable instance has different state)

Hi, I can't figure out what to use for scheduling and pooling runnables of different state (each Runnable instance has different state). I could use ScheduledExecutorFactoryBean together with MethodInvokingRunnable to supply arguments. But take a look at the key ScheduledExecutorFactoryBean method, it is designed in a way that all task s...

Port scanning using threadpool

I am trying to run a small app that scans ports and checks to see if they are open using and practicing with threadpools. The console window will ask a number and scans ports from 1 to X and will display each port whether they are open or closed. My problem is that as it goes through each port, it sometimes stops prematurely. It doesn...

Threadpool design question

I have a design question. I want some feedback to know if a ThreadPool is appropriate for the client program I am writing. I am having a client running as a service processing database records. Each of these records contains connection information to external FTP sites [basically it is a queue of files to transfer]. A lot of them are...

TaskFactory.StartNew versus ThreadPool.QueueUserWorkItem

Apparently the TaskFactory.StartNew method in .NET 4.0 is intended as a replacement for ThreadPool.QueueUserWorkItem (according to this post, anyway). My question is simple: does anyone know why? Does TaskFactory.StartNew have better performance? Does it use less memory? Or is it mainly for the additional functionality provided by the T...

C# How to count managed threads in my AppDomain?

Is there a way to find out how many managed thread I use (including ThreadPool)? When I get count of unmanaged threads through GetProcess I have an insane number of it (21 at very beginning) ...

Task Parallel Library; TaskCreationOptions.LongRunning option and ThreadPool

Background: "The Task Parallel Library (TPL) is a set of public types and APIs in the System.Threading and System.Threading.Tasks namespaces in the .NET Framework version 4. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications." TPL uses Task Schedu...

How do I get the PrivilegedProcessorTime and UserProcessorTime for the current thread

I found several examples of how to get the PrivilegedProcessorTime and UserProcessorTime for a process and for all threads, but how do I get the PrivilegedProcessorTime and UserProcessorTime for the current managed thread. private void button1_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(new WaitCallback(WorkCore...

ThreadPool - WaitAll 64 Handle Limit

I am trying to bypass the the wait64 handle limit that .net 3.5 imposes I have seen this thread : http://stackoverflow.com/questions/2702545/workaround-for-the-waithandle-waitall-64-handle-limit So I understand the general idea but I am having difficulty because I am not using a delegate but rather I am basically working of this exam...