Created
February 22, 2017 09:26
-
-
Save njsmith/58e81cc8b6c63fc40aca46e64d33aa9c 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
| PARALLEL = False | |
| COUNT = 1000000000 | |
| import threading | |
| import time | |
| def count(): | |
| n = COUNT | |
| while n > 0: | |
| n -= 1 | |
| if PARALLEL: | |
| t1 = threading.Thread(target=count) | |
| t1.start() | |
| t2 = threading.Thread(target=count) | |
| t2.start() | |
| t1.join() | |
| t2.join() | |
| else: | |
| count() | |
| count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment