From: Stephen Toub Date: Tue, 5 Jan 2021 18:15:29 +0000 (-0500) Subject: Remove ThreadStart delegate allocation from TryCreateWorkerThread (#46563) X-Git-Tag: submit/tizen/20210909.063632~3944 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9801d8a8e43904487eb430d8d11a7517384b2403;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove ThreadStart delegate allocation from TryCreateWorkerThread (#46563) --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs index c151d9f..e4b574e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs @@ -27,6 +27,8 @@ namespace System.Threading } }); + private static readonly ThreadStart s_workerThreadStart = WorkerThreadStart; + private static void WorkerThreadStart() { Thread.CurrentThread.SetThreadPoolWorkerThreadName(); @@ -290,7 +292,7 @@ namespace System.Threading { // Thread pool threads must start in the default execution context without transferring the context, so // using UnsafeStart() instead of Start() - Thread workerThread = new Thread(WorkerThreadStart); + Thread workerThread = new Thread(s_workerThreadStart); workerThread.IsThreadPoolThread = true; workerThread.IsBackground = true; workerThread.UnsafeStart();