<Futr> = <Exec>.submit(<func>, <arg_1>, ...) # Creates a thread and returns its Future object.
<Exec>.shutdown(wait=True) # Blocks until all threads finish executing.
<Exec>.shutdown(wait=True) # Blocks until all threads finish executing.
```
```
@ -2153,7 +2153,7 @@ with <lock>: # Enters the block by calling acq
<iter> = as_completed(<coll_of_Futures>) # Each Future is yielded as it completes.
<iter> = as_completed(<coll_of_Futures>) # Each Future is yielded as it completes.
```
```
* **Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.**
* **Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.**
* **Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. It's exception() method returns exception or None.**
* **Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. Its exception() method returns exception or None.**
* **An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments and results must be [pickable](#pickle).**
* **An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments and results must be [pickable](#pickle).**
<lock>.release() <spanclass="hljs-comment"># Makes the lock available again.</span>
<lock>.release() <spanclass="hljs-comment"># Makes the lock available again.</span>
</code></pre></div>
</code></pre></div>
<div><h4id="or-1">Or:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">with</span><lock>: <spanclass="hljs-comment"># Enters the block by calling acquire(),</span>
... <spanclass="hljs-comment"># and exits it with release(), even on error.</span>
<div><h4id="or-1">Or:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">with</span><lock>: <spanclass="hljs-comment"># Enters the block by calling acquire() and</span>
... <spanclass="hljs-comment"># exits it with release(), even on error.</span>
</code></pre></div>
</code></pre></div>
<div><h3id="semaphoreeventbarrier">Semaphore, Event, Barrier</h3><pre><codeclass="python language-python hljs"><Semaphore> = Semaphore(value=<spanclass="hljs-number">1</span>) <spanclass="hljs-comment"># Lock that can be acquired by 'value' threads.</span>
<div><h3id="semaphoreeventbarrier">Semaphore, Event, Barrier</h3><pre><codeclass="python language-python hljs"><Semaphore> = Semaphore(value=<spanclass="hljs-number">1</span>) <spanclass="hljs-comment"># Lock that can be acquired by 'value' threads.</span>
<Futr> = <Exec>.submit(<func>, <arg_1>, ...) <spanclass="hljs-comment"># Creates a thread and returns its Future object.</span>
<Exec>.shutdown(wait=<spanclass="hljs-keyword">True</span>) <spanclass="hljs-comment"># Blocks until all threads finish executing.</span>
<Exec>.shutdown(wait=<spanclass="hljs-keyword">True</span>) <spanclass="hljs-comment"># Blocks until all threads finish executing.</span>
<li><strong>Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.</strong></li>
<li><strong>Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.</strong></li>
<li><strong>Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. It's exception() method returns exception or None.</strong></li>
<li><strong>Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. Its exception() method returns exception or None.</strong></li>
<li><strong>An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments and results must be <ahref="#pickle">pickable</a>.</strong></li>
<li><strong>An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments and results must be <ahref="#pickle">pickable</a>.</strong></li>
</ul>
</ul>
<div><h2id="operator"><ahref="#operator"name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op
<div><h2id="operator"><ahref="#operator"name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op