This code will compile fine but give run time exception. I agree with that but i still believe that there should be a compile time error with this code at line 1, since bm.go() calls method public void go() which is not static.
Also go() calls start() method which is not static . Hence we can't make the line no 2 public static void go() which will give compilation error.
Why do you think that there should be a problem with calling non-static methods?
What are the conditions to be satisfied when calling notifyAll (or wait, or notify)? Look at the exception you are getting, you know what it means? [ March 08, 2007: Message edited by: Barry Gaunt ]
when you call 'wait','notifyAll' and 'notify', you must have the lock on the object, otherwise you'll get a 'IllegalMonitorStateException' =] [ March 08, 2007: Message edited by: Andr� Junior ]
From the book: wait(), notify(), and notifyAll() must be called from within a synchronized context! A thread can't invoke a wait or notify method on an object unless it owns that object's lock. See SCJP book, page 720.
I understood the problem that while calling the go method (bm.go()) it was called from the bm instance's context and not from the static context and thats why even the go method is non static it's not giving any error.