queue - How to set max number of threads running concurrently using ThreadPool in .NET -
i need execute fixed number of threads,say 5, in parallel, , en-queue remaining threads. here piece of code tried.
threadpool.setmaxthreads(5, 0); threadpool.queueuserworkitem(new waitcallback(threadproc), task1); thread.sleep(1000);//'threadproc' callback function
now, when i'm trying run, 7 threads in parallel running threads simultaneously instead of running 5 thread , queuing next 2 threads. how achieve this?
if can use parallel for/foreach have paralleloptions.maxdegreeofparallelism
limit number of concurrent operations.
Comments
Post a Comment