[concurrency-interest] Creating custom locks

Larry Riedel larryr@saturn.sdsu.edu
20 Nov 2003 04:59:04 -0000

> >     final void checkOwner(Thread t) { //why final
> >         if (owner != t)
> >             throw new IllegalMonitorStateException();
> >     }
> > }
> Why would you want to override this? It is a simple little
> helper function. Is final really the problem here or
> the lack of access?  I have no problem with making this
> protected, but I wouldn't want anyone to override this to
> not check ownership, for example.

Is the preference to make methods final unless there is a
good reason not to, or is the preference to preclude users
of a class from overriding methods if by doing so they may
cause the method to violate its contract with the caller,