1. Note that t1.join(); says that put the current thread on hold until thread t1 has finished.
2. In your example, t1 thread does not even exist - thread only exist after a call to its start() method.
To see join() in action, I have just made slight change to your program. Try it with and without the t1.join();. You will then see how join() works.
Hope this helps.
class TechnoSample {
public static void main(
String[] args) throws Exception{
Thread t1 = new Thread(getRunnable(20, "t1"));
Thread t2 = new Thread(getRunnable(10, "t2"));
t1.start();
//t1.join();
t2.start();
System.out.println("End");
}
public static Runnable getRunnable(final int id, final String name){
return new Runnable(){
public void run(){
for(int i = 0; i < id; i++){
System.out.print(name+i + " ");
}
}
};
}}