python - My understanding of threading -


i have not programmed in on year sorry if stupid question. looked lots of examples on site threading seem getting different outcome other people.

from understanding of threading, using simple code, should printing yo , lo together,

yo lo yo lo

but instead

yo yo yo ...

from threading import thread  import time  def printyo():         while(3>1):             print ("yo")             time.sleep(1)  def printlo():         while(3>1):             print ("lo")             time.sleep(1)  t2 = thread(target=printlo()) t = thread(target=printyo()) t2.start() t.start() 

you calling function instead of giving target thread.

t2 = thread(target=printlo) t = thread(target=printyo) 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -