Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>there are a lot of misconceptions here: </p> <ul> <li><p>you can only start a specific instance of a thread once. but in your case, the for loop is looping over different instances of a thread, each instance being assigned to the variable <code>thread</code> in the loop, so there is no problem at all in calling the <code>start()</code> method over each thread. (you can think of it as if the variable <code>thread</code> is an alias of the <code>Thread()</code> object instantiated in your list)</p></li> <li><p><code>run()</code> is not the same as <code>join()</code>: calling <code>run()</code> performs as if you were programming sequentially. the <code>run()</code> method does not start a new thread, it simply execute the statements in in the method, as for any other function call. </p></li> <li><p><code>join()</code> does note start executing anything: it only waits for a thread to finish. in order for <code>join()</code> to work properly for a thread, you have to call <code>start()</code> on this thread first.</p></li> </ul> <p>additionally, you should not that you cannot restart a thread once it has finished execution: you have to recreate the thread object for it to be started again. one workaround to get this working is to call <code>Thread.__init__()</code> at the end of the <code>run()</code> method. however, i would not recommend doing this since this will disallow the use of the <code>join()</code> method to detect the end of execution of the thread.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload