What do you mean by "synchronize the object"?
Let me explain by confusing you first
Although it is common to talk about a "synchronized object", you could argue that
there is actually no such thing. Objects aren't really synchronized.
Operations are.
That, I guess, is why a lot of developers get into trouble when they use the synchronized collection classes like Hashtable (don't use that - use Collections.synchronizedMap(new HashMap()) if you must). They take a threadsafe Map, then start writing their code against it thinking it'll be threadsafe because the underlying Map "is threadsafe".
It won't be. Your code is essentially defining new, more complicated operations on the Map that are probably not threadsafe at all.
So to rephrase my question: "What operations do you think need synchronizing (and why)"?
- Peter
PS. For one interpretation of "making an object synchronized", see the source for Collections.synchronizedCollection(Collection) and friends.
[ February 08, 2002: Message edited by: Peter den Haan ]