How to wait until all threads are ready before start them
<p>I have this working script:</p>

<pre><code>import socket, threading

def loop():
    global threads
    get_host = "GET " + url + " HTTP/1.1\r\nHost: " + url + "\r\n"
    accept = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n"
    connection = "Connection: Keep-Alive\r\n"
    useragent = "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\r\n"
    request = get_host + useragent + accept + connection + "\r\n"
    for x in range(800): 
        send().start() 

class send(threading.Thread):

    def run(self):
        self.requestdefault()
    def requestdefault(self):
        while True:
            try:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.connect((str(url), int(urlport)))
                s.send (str.encode(request))
                print ("Request sent!")
            except:
                pass

loop()
</code></pre>

<p>How can I let wait program before all threads are ready before starting them end send request? </p>

<p>Maybe you need some notification mechanics. I think you should try event object like below snippet: </p>

<pre><code>import threading
import time

event=threading.Event()

def main_thread():
    time.sleep(10)
    event.set() # notify, enable worker thread run

def worker_thread():
    event.wait()
    print threading.currentThread().name +" running \n"

if __name__=='__main__':
    for i in xrange(0,2):
        t=threading.Thread(target=worker_thread)
        t.start()
    main_thread()
</code></pre>

python multithreading python-3.x