when i compile this i just get thread waiting but not getting notified.....
but when i compile other codehere my thread gets notified???why cant previous thread get notified???how to get it notified???
problem in your code is you are not starting any new thread whole program is running under one single main thread so when you call show method it puts the thread to wait and the code that notifies the thread is never reached.
but in the second code you used overloaded version of wait which comes to runnable after the time specified no matter it is notified or not.
I find your code highly unreadable and confusing. It took me a couple of times reading it before I got it. It's generally discouraged to extend the thread class. Why not use Runnables? I think this code is better readable:
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.