Last active
September 20, 2016 03:00
-
-
Save dongweiming/afecc286fa1d73e5c3652776030bbcaa to your computer and use it in GitHub Desktop.
test
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
import threading | |
count = 0 | |
def incre(): | |
global count | |
count += 1 | |
def bye(): | |
while 1: | |
incre() | |
def hello_there(): | |
while 1: | |
incre() | |
def main(): | |
for func in [hello_there, bye]: | |
t = threading.Thread(target=func) | |
t.start() | |
while 1: | |
print count | |
main() |
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
import threading | |
result = [0] | |
def incre(): | |
global result | |
result.append(max(result) + 1) | |
def bye(): | |
while 1: | |
incre() | |
def hello_there(): | |
while 1: | |
incre() | |
def main(): | |
for func in [hello_there, bye]: | |
t = threading.Thread(target=func) | |
t.start() | |
while 1: | |
print result | |
main() |
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
import threading | |
result = [0] | |
def incre(): | |
global result | |
result.extend([max(result) + 1]) | |
def bye(): | |
while 1: | |
incre() | |
def hello_there(): | |
while 1: | |
incre() | |
def main(): | |
for func in [hello_there, bye]: | |
t = threading.Thread(target=func) | |
t.start() | |
while 1: | |
print result | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment