Utility methods that create thread safe wrappers around the core
abstractions of this package. Uses synchronization on mutexes around method
calls; the arguments provided to the various methods are not modified
themselves. You should take care to ensure that no references to the
unwrapped objects are kept because method calls on those objects might
produce concurrency problems. For example, the followin should not
be used:
Adapter adapter = new DefaultAdapter();
Adapter synchronizedAdapter =
SynchronizationUtil.synchronizedAdapter(adapter);
doThings(adapter);
doThingsInANewThread(synchronizedAdapter);
Rather, use a coding pattern like the following:
Adapter adapter =
SynchronizationUtil.synchronizedAdapter( new DefaultAdapter() );
author: Leo Simons version: $Id: SynchronizationUtil.java,v 1.7 2004/03/23 13:37:51 lsimons Exp $ |