Two doubts:
1. Placing run() inside main() generates "illegal start of expression error"? So why can't run() be placed inside main()?

2.With the above code I am getting the output as A C D B. Why B comes last is because of join(). But what I'm unable to understand is that on invoking start() shouldn't run() get called immediately thus generating the output as C D A B?

Help please..Thanks

  1. You can't define one method inside another - that's just the Java langauge definition. (except when the second method is inside an inner class defined inside a method...)
  2. After executing t.start()) you have two threads withe same priority and no synchronisation, so you have no control or knowledge about the order in which they will be executed.

Oh great that makes it much more clear :)