You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
477 B
27 lines
477 B
#!/usr/bin/python |
|
# -*- coding: utf-8 -*- |
|
|
|
# "Global Interpreter Lock" - Only one thread :( |
|
# Don't expect more. |
|
|
|
import thread |
|
import time |
|
|
|
def worker_thread(id) : |
|
|
|
print "Thread ID start: %d" % id |
|
|
|
count = 1 |
|
|
|
while True : |
|
print "Thread ID: %d with value %d" % (id, count) |
|
time.sleep(2) |
|
count += 1 |
|
|
|
for i in range(5) : |
|
thread.start_new_thread(worker_thread, (i,)) |
|
|
|
print "Main thread goes with an infinite loop." |
|
|
|
while True : |
|
pass
|
|
|