Skip to content

Instantly share code, notes, and snippets.

@lkuper
Created January 13, 2014 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkuper/8393555 to your computer and use it in GitHub Desktop.
Save lkuper/8393555 to your computer and use it in GitHub Desktop.
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