Skip to content

Instantly share code, notes, and snippets.

@shanemhansen
Created October 2, 2011 23:41
Show Gist options
  • Save shanemhansen/1258115 to your computer and use it in GitHub Desktop.
Save shanemhansen/1258115 to your computer and use it in GitHub Desktop.
creating a simple python thread
import thread
import time
def run():
start=1
while 1:
start=start*2
thread.start_new_thread(run,())
thread.start_new_thread(run,())
time.sleep(1000)
shansen@moki:~$ ls /proc/13705/task/
13705 13706
import os
import thread
import time
print "run ls /proc/%s/task/ to see active threads"%(os.getpid(),)
def run():
while 1:
time.sleep(100)
t=thread.start_new_thread(run,())
time.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment