From: Matthew Kerwin Date: 2012-05-16T16:31:44+09:00 Subject: Re: How to ensure that a block runs entirely after other threads? (Thread.exclusive does not "work") On 16 May 2012 17:27, Robert Klemme wrote: > Do I understand that correctly that you want to have 1 thread run > exclusively in the interpreter?  If that's the case I agree with Eric: > that's a bad idea.  You only need to synchronize access to shared > resources.  If there are threads which do not access the shared > resource there is no point in blocking them. > > I do not know your sharing and exclusiveness requirements but one > helpful option might be a read write lock.  Or, of course, a regular > mutex.  In any case you need to define in code which threads share > which resources and hence require exclusive access. > > Kind regards > > robert Keeping in mind that things like "the screen" are a resource; so if you want to synchronise your output you can create a lock to restrict access to STDOUT, or any printing/writing methods, or whatever is appropriate. I find reentrant read-write locks are the easiest synchronising mechanisms to keep straight in my head, but they could be pretty heavy overkill for some applications. --   Matthew Kerwin, B.Sc (CompSci) (Hons)   http://matthew.kerwin.net.au/   ABN: 59-013-727-651   "You'll never find a programming language that frees   you from the burden of clarifying your ideas." - xkcd