def multi_thread():
    global terms
    terms =[]
    threads=[]

    for i in range(args.quantity):
        name = '%s-%s' % (args.name,i)
        t = threading.Thread(target=start_terminal_worker, args=(name,), name=name)
        threads.append(t)
        t.setDaemon(True)
        print 'Initializying %s' % name
        if i%3 == 0:
            time.sleep(int(int(args.quantity) * 0.04) + 1)
        t.start()

    for th in range(len(threads)):
        while threads[th].is_alive():
            time.sleep(1)

    if args.ports is not None:
        threads=[]
        host_subdomain=socket.gethostname()
        ports=args.ports.split(',')
        terms.append(terminal.get_terminal(None,host_subdomain)['terminal'])
        for term in range(len(terms)):
            container_key=terms[term]['container_key']
            links=[]
            for s in range(len(terms)):
                for port in range(len(ports)):
                    link={'port':str(ports[port]),'source':terms[s]['subdomain']}
                    links.append(link)
            t = threading.Thread(target=add_terminal_links_worker, args=(container_key,links), name=terms[term]['subdomain'])
            threads.append(t)
            t.setDaemon(True)
            if (term + 1)%8 == 0:
                time.sleep(int(int(len(terms)) * 0.02) + 1)
            print t.name % '%s -  Configuring links'
            t.start()

        for th in range(len(threads)):
            while threads[th].is_alive():
                time.sleep(1)
    return terms
dataset/ETHPy150Open terminalcloud/terminal-tools/script-terminals.py/multi_thread/swapped operands of `%`