Created
January 13, 2014 02:07
-
-
Save lkuper/8393555 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
import threading | |
class LVar(object): | |
def __init__(self): | |
self.value = 0 | |
def get(self, threshold): | |
while not self.value >= threshold: | |
pass | |
return | |
def put(self, value): | |
self.value = max(self.value, value) | |
l = LVar() | |
class Thread1(threading.Thread): | |
def run(self): | |
print("invoking get") | |
l.get(3) | |
print("get returned") | |
class Thread2(threading.Thread): | |
def run(self): | |
print("putting 1") | |
l.put(1) | |
class Thread3(threading.Thread): | |
def run(self): | |
print("putting 5") | |
l.put(5) | |
Thread1().start() | |
Thread2().start() | |
Thread3().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment