Created
October 2, 2011 23:41
-
-
Save shanemhansen/1258115 to your computer and use it in GitHub Desktop.
creating a simple python thread
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 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) |
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
shansen@moki:~$ ls /proc/13705/task/ | |
13705 13706 |
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 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