Re: Vector (was Re: Change character in string)
On Sun, 15 Mar 2009, Ken T. wrote:
On Sun, 15 Mar 2009 13:18:01 -0700, Little Green Man wrote:
The evil mythical being is in the details is it not?
Sun should add a construct
synchronized (x, y, z, ...) {
}
that allows any number of items in the parentheses and always locks the
same set of objects in a deterministic order.
I like this idea, but rather than all the detail below, why not require
x, y, and z to be of the same type and to implement Comparable? That
would solve the issue wouldn't it?
As long as their compareTo methods are threadsafe but not synchronized ...
And even then, this is less general than a more detaily approach. What if
you really want to lock several objects which can't be mutually
comparable? How would you make Lists, the original example here,
comparable (without restricting them to containing comparable elements)?
tom
--
There is no violence or enmity in the LEGO universe until you, the
builder, decide what to build with the pieces. -- Pyrogenic