Last active
February 13, 2019 03:36
-
-
Save hankliu5/1674203a7eb402b01829c684fcd34d77 to your computer and use it in GitHub Desktop.
This file contains 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
from threading import Thread | |
import time | |
def count(): | |
i = 0 | |
for _ in range(50000000): | |
i += 1 | |
return True | |
def main(): | |
thread_table = {} | |
start_time = time.time() | |
for tid in range(4): | |
t = Thread(target=count) | |
t.start() | |
thread_table[tid] = t | |
t.join() | |
end_time = time.time() | |
print("Total time: {} secs".format(end_time - start_time)) | |
if __name__ == '__main__': | |
main() | |
# Total time: 13.2221679688 secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment