|
[php]
#!/usr/bin/python
#Filename:helloMT.py
import thread,os
def ant(i):
global sum,lock
lock.acquire()
sum += i
lock.release()
print i,sum
lock = thread.allocate_lock()
sum = 0
print thread.start_new_thread(ant,(20,))
print thread.start_new_thread(ant,(5,))
[/php]
线程不工作? |
|