/**
* Make a thread-safe copy of the specified object.
* If it is immutable, then just return it; otherwise
* we make a serialized copy.
*/
public static object safe(object obj)
{
if (obj == null)
{
return(null);
}
if (FanObj.isImmutable(obj))
{
return(obj);
}
Buf buf = new MemBuf(512);
buf.writeObj(obj);
buf.flip();
return(buf.readObj());
}