From ff84bad13884c5b49900c03a9fcd9a84f718c2a1 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 29 Jan 2025 10:17:42 +0100 Subject: [PATCH] Reword warning about slow thread creation in Using multiple threads --- tutorials/performance/using_multiple_threads.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tutorials/performance/using_multiple_threads.rst b/tutorials/performance/using_multiple_threads.rst index b355fd49c..1943162e7 100644 --- a/tutorials/performance/using_multiple_threads.rst +++ b/tutorials/performance/using_multiple_threads.rst @@ -141,9 +141,17 @@ wait until the thread is done (if not done yet), then properly dispose of it. .. warning:: - Creating threads at runtime is slow on Windows and should be avoided to - prevent stuttering. Semaphores, explained later on this page, should be used - instead. + Creating threads is a slow operation, especially on Windows. To avoid + unnecessary performance overhead, make sure to create threads before heavy + processing is needed instead of creating threads just-in-time. + + For example, if you need multiple threads during gameplay, you can create + threads while the level is loading and only actually start processing with + them later on. + + Additionally, locking and unlocking of mutexes can also be an expensive + operation. Locking should be done carefully; avoid locking too often (or for + too long). Mutexes -------