smbinterp/tools/multi/smp.py

25 lines
400 B
Python
Raw Normal View History

2009-12-27 09:48:27 -08:00
#!/usr/bin/python
from multiprocessing import Process, Lock
def f(l, i, d):
d['a'] = 'shutup'
print 'hello world', i, d
j = 0.0
for i in xrange(10000000):
2009-12-27 09:48:27 -08:00
j = j + j/2.0
if __name__ == '__main__':
lock = Lock()
d = {'a': 1, 'b': 2}
ps = []
for num in range(2):
ps.append(Process(target=f, args=(lock, num, d)))
for p in ps: p.start()
for p in ps: p.join()
print d