Created
December 2, 2020 05:02
-
-
Save teguhteja/2569d6e822925fcf8ad66fd09ce1a27e to your computer and use it in GitHub Desktop.
Example code threading from https://www.youtube.com/watch?v=4hcnEWNsf_w&list=WL&index=2
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
import threading | |
def count_operation(): | |
for i in range(100): | |
print(threading.current_thread().getName() + '-' + str(i)) | |
# this is sequential execution - operation right after each other | |
count_operation() | |
t1 = threading.Thread(target=count_operation, name='Adam') | |
t2 = threading.Thread(target=count_operation, name='Bob') | |
t1.start() | |
t2.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment