frist off ,in your program ,there exist two thread ,one is t1,the other is main thread(we called) t1 need to own the lock which is the instance of TestThread
and then invoke wait() method.the main thread is need to own the lock which is the samne as t1 and then invoke notify() method
I think you expect the jvm will invoke the t1 frist ,but we can not assure.
if you only want to invoke the thread t1 frist ,you can do the following
and then o/p
generally speaking the jvm will execute parts code of main thread(personal opinion :the jvm assure all the thread which are created start in time) and then
execute the thread t1,so will appear the thread t1 always waiting
Also what will happen if I replace synchronized(this) in startMe() method will synchronized(ThreadO.class) ?
also the static lock is apply to static field or static method
[ April 08, 2006: Message edited by: Changchun Wang ]