Skip to content

Instantly share code, notes, and snippets.

@chavarera
Created April 5, 2019 03:01
Show Gist options
  • Save chavarera/d86a806ecfbb07c55711d0828056c69b to your computer and use it in GitHub Desktop.
Save chavarera/d86a806ecfbb07c55711d0828056c69b to your computer and use it in GitHub Desktop.
pythonthreading
import threading
def Func1(num):
cal=num*10000
print("\nI am From Func1 ")
def Func2(num):
print("\nI am from Func2".format(num * num))
if __name__ == "__main__":
t1 = threading.Thread(target=Func1, args=(10,))
t2=threading.Thread(target=Func2,args=(11,))
t1.start()
t2.start()
t1.join()
t2.join()
print("\nDone")
import queue
from threading import Thread
def foo(bar):
print('hello {0}'.format(bar))
return 'foo'
que = queue.Queue()
fn=lambda q,arg1:q.put(foo(arg1))
t = Thread(target=fn, args=(que, 'world!'))
t.start()
t.join()
result = que.get()
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment