Ticket #20286: threadboom.py
| File threadboom.py, 422 bytes (added by santagada@…, 3 years ago) |
|---|
| Line | |
|---|---|
| 1 | import threading |
| 2 | import mimetypes |
| 3 | import time |
| 4 | |
| 5 | race_flag = threading.Event() |
| 6 | |
| 7 | class Thread(threading.Thread): |
| 8 | def run(self): |
| 9 | race_flag.wait() |
| 10 | mimetypes.guess_type('sss') |
| 11 | |
| 12 | |
| 13 | threads = [] |
| 14 | for i in range(5): |
| 15 | t = Thread() |
| 16 | t.start() |
| 17 | threads.append(t) |
| 18 | |
| 19 | time.sleep(0.5) |
| 20 | print "Run Run Run" |
| 21 | race_flag.set() |
| 22 | time.sleep(1) |
| 23 | [t.join() for t in threads] |
| 24 | print "Your interpreter didn't blow up... sorry" |
| 25 |

