Python start all Threads from doulbe FOR LOOP
<p>I have this kind of scenario:</p>

<pre><code>threads = []
for wordToScan in wordsList:
    dictionaryFileOpen = open(dictionaryFile, "r")

    for i in range(10):
        threads.append(Thread(target=words_Scan_Start, args=(dictionaryFileOpen, wordToScan)))

for thread in threads:
    thread.start()
for thread in threads:
    thread.join()

def words_Scan_Start(dictionaryFile, wordToScan):
    while True:
        sub_word = dictionaryFile.readline()
        if not sub_word:
            break
        #... Here is some actions.
</code></pre>

<p>Now I need to start all these threads at once(10 threads each for every <code>wordToScan in wordsList</code>).</p>

<p>Every <code>wordToScan in wordsList:</code> should use <code>dictionaryFileOpen</code> in 10 threads but without moving <code>.readline()</code> for the other <code>wordToScan in wordsList:</code> that working at the same time. Also, I can't understand where is to close the <code>dictionaryFileOpen</code>.</p>

<p>Here is how I have it done:</p>

<pre><code>threads = []
for wordToScan in wordsList:
    wordThread = []
    dictionaryFileOpen = open(dictionaryFile, "r")

    for i in range(10):
        wordThread.append(Thread(target=words_Scan_Start, args=(dictionaryFileOpen, wordToScan)))
    threads.append(wordThread)

for thread in threads:
    for wordThread in thread:
        wordThread.start()
for thread in threads:
    for wordThread in thread:
        wordThread.join()
    dictionaryFileOpen.close()

def words_Scan_Start(dictionaryFile, wordToScan):
    while True:
        sub_word = dictionaryFile.readline()
        if not sub_word:
            break
        #... Here is some actions.
</code></pre>

<p>Am I doing it right?</p>

python multithreading readline