From: "Iñaki Baz Castillo" Date: 2012-05-16T16:49:57+09:00 Subject: Re: How to ensure that a block runs entirely after other threads? (Thread.exclusive does not "work") 2012/5/16 Robert Klemme : > That's a perfectly appropriate way to handle that: you don't want to > incur synchronization overhead for all users even if they do not need > access from multiple threads.  Even worse, there are cases where only > the user can decide which synchronization is appropriate.  For example > the infamous cache idiom > > if cache.include? x >  y = cache.get(x) > else >  y = create_y(x) >  cache.put(x, y) > end > > (I know, which Hash there are more elegant solutions - this is for > illustration purposes only.) > > In this case you cannot guarantee consistency by internally > synchronizing all methods of "cache" if it must be avoided that two > threads invoke create_y() for the same x. 100% agreed. Thanks a lot. -- Iñaki Baz Castillo