there is an object creation of type Thread but the stament dont have any
terminating semi-colon, instead there is a block opening.
and the block ends at line 12.
what kind of syntax is this? is there anybody to explain me?
(i guess it that this is not an advance topic, it is likely to be related with basics of java, but i could not figure out)
Expand|Select|Wrap|Line Numbers
- public class Joining {
- static Thread createThread(final int i, final Thread t1) {
- Thread t2 = new Thread() { // line 3
- public void run() {
- System.out.println(i+1);
- try { t1.join(); }
- catch (InterruptedException e) { }
- System.out.println(i+2);
- }
- }; // line 12
- System.out.println(i+3);
- t2.start();
- System.out.println(i+4);
- return t2;
- }
- public static void main(String[] args) {
- createThread(10, createThread(20, Thread.currentThread()));
- }
- }