Created
December 30, 2015 18:57
-
-
Save pixyj/336545faf57db3c37c51 to your computer and use it in GitHub Desktop.
Thread and Queue Python example - blast from my past
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 Queue | |
import threading | |
class PrintMsg(threading.Thread): | |
def __init__(self,queue): | |
threading.Thread.__init__(self) | |
self.queue = queue | |
def run(self): | |
while True: | |
print "waiting for msg" | |
msg = self.queue.get() | |
print "Msg received {}".format(msg) | |
queue = Queue.Queue() | |
printMsg = PrintMsg(q) | |
printMsg.start() | |
while True: | |
msg = raw_input("Enter the msg\n") | |
queue.put(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment