Synchronization issue using Python's multiprocessing module
问题 When I run the following code in from Python's multiprocessing module page: from multiprocessing import Process, Lock def f(l, i): l.acquire() print 'hello world', i l.release() if __name__ == '__main__': lock = Lock() for num in range(10): Process(target=f, args=(lock, num)).start() Sometimes I get unordered output such as: hello world 0 hello world 1 hello world 2 hello world 4 hello world 3 hello world 6 hello world 5 hello world 7 hello world 8 hello world 9 Note that 4 is printed before