A program that creates several processes that work on a join-able queue, Q
, and may eventually manipulate a global dictionary D
to store results. (so each child process may use D
to store its result and also see what results the other child processes are producing)
If I print the dictionary D in a child process, I see the modifications that have been done on it (i.e. on D). But after the main process joins Q, if I print D, it's an empty dict!
I understand it is a synchronization/lock issue. Can someone tell me what is happening here, and how I can synchronize access to D?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…