Service Activator Toolkit
Version 1.0.0

org.eclipse.soda.sat.core.framework.interfaces
Interface IThreadLocal


public interface IThreadLocal

The IThreadLocal interface defines an API for storing data on a per thread basis. This general purpose utility is useful for implementing multi-threaded applications. An instance of IThreadLocal can be created using the FactoryUtility singleton.

 FactoryUtility utility = FactoryUtility.getInstance();
 IThreadLocal threadLocal = utility.createThreadLocal();
 
The API is extremely simple in that thread specific data is stored using the set(Object) method, and thread specific data is retrieved using the get() method. The value null will be returned by the method get() if it is called by a thread before it has called the method set(Object). Note: It is important that before a thread stops that it removes its data from the IThreadLocal by calling set(null). Failure to do so can result in object retention, preventing the stored data from being garbage collected. This is both a poor programming practice and illegal per the OSGi specification.

See Also:
FactoryUtility

Method Summary
 Object get()
          Get the Object for the current thread.
 void set(Object value)
          Set the Object for the current thread.
 

Method Detail

get

public Object get()
Get the Object for the current thread.

Returns:
The Object.

set

public void set(Object value)
Set the Object for the current thread.

Parameters:
value - An Object.

Service Activator Toolkit
Version 1.0.0