@ -1731,7 +1731,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
< li > < strong > CPython interpreter can only run a single thread at a time.< / strong > < / li >
< li > < strong > That is why using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.< / strong > < / li >
< / ul > < pre > < code class = "python language-python hljs" > < span class = "hljs-keyword" > from< / span > threading < span class = "hljs-keyword" > import< / span > Thread, RLock, Semaphore, Event, Barrier
< span class = "hljs-keyword" > from< / span > concurrent.futures < span class = "hljs-keyword" > import< / span > ThreadPoolExecutor
< span class = "hljs-keyword" > from< / span > concurrent.futures < span class = "hljs-keyword" > import< / span > ThreadPoolExecutor, as_completed
< / code > < / pre > < / div >
@ -1771,6 +1771,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
< Futr> = < Exec> .submit(< func> , < arg_1> , ...) < span class = "hljs-comment" > # Starts a thread and returns its Future object.< / span >
< bool> = < Futr> .done() < span class = "hljs-comment" > # Checks if the thread has finished executing.< / span >
< obj> = < Futr> .result() < span class = "hljs-comment" > # Waits for thread to finish and returns result.< / span >
< iter> = as_completed(< coll_of_Futr> ) < span class = "hljs-comment" > # Each Future is yielded as it completes.< / span >
< / code > < / pre >
< div > < h3 id = "queue" > Queue< / h3 > < p > < strong > A thread-safe FIFO queue. For LIFO queue use LifoQueue.< / strong > < / p > < pre > < code class = "python language-python hljs" > < span class = "hljs-keyword" > from< / span > queue < span class = "hljs-keyword" > import< / span > Queue
< Queue> = Queue(maxsize=< span class = "hljs-number" > 0< / span > )