线程池线程
转载There are a number of ways to enter the thread pool:
Via the Task Parallel Library (from Framework 4.0)
By calling ThreadPool.QueueUserWorkItem
Via asynchronous delegates
Via BackgroundWorker
The following constructs use the thread pool indirectly:
· WCF, Remoting, ASP.NET, and ASMX Web Services application servers
· System.Timers.Timer and System.Threading.Timer
· Framework methods that end in Async, such as those on WebClient (the event-based asynchronous pattern),and most BeginXXX methods (the asynchronous programming model pattern)
· PLINQ
There are a few things to be wary of when using pooled threads:
· You cannot set the Name of a pooled thread, making debugging more difficult (although you can attach a description when debugging in Visual Studio’s Threads window).
· Pooled threads are always background threads (this is usually not a problem).
· Blocking a pooled thread may trigger additional latency in the early life of an application unless you call ThreadPool.SetMinThreads (see Optimizing the Thread Pool).
You are free to change the priority of a pooled thread—it will be restored to normal when released back to thepool.
You can query if you’re currently executing on a pooled thread via the property:Thread.CurrentThread.IsThreadPoolThread.
上一篇:使用异步方式调用同步方法
下一篇:Lock方法
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java 线程池 ThreadPoolExecutor
记录线程池的使用
线程池 java ide