Created
December 28, 2013 11:07
-
-
Save anonymous/8158332 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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