Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2013 11:07
Show Gist options
  • Save anonymous/8158332 to your computer and use it in GitHub Desktop.
Save anonymous/8158332 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
# run as this echo -e '5\n2\n1\n3\n4.2' | python tsort.py
import time
import threading
import fileinput
def do(value):
time.sleep(float(value))
print value.strip()
def main():
number_list = []
tlist = []
for i in fileinput.input():
number_list.append(i)
for i in number_list:
tid = threading.Thread(target=do, args=(i, ))
tid.start()
tlist.append(tid)
for t in tlist:
t.join()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment