I have the following code on threads.I have a doubt that is it possible that any of the two threads created ie one and two will execute the 2nd print statement in run method before the first print statement in it?That is print hello first and then the current thread name
public class HelloWorld {
public static void main(String []args){
System.out.println("Hello World");
Runnable r = new Animal();
Thread t =new Thread(r);
Thread t1 =new Thread(r);
t.start();
t.setName("one");
t1.start();
t1.setName("two");
System.out.println(Thread.currentThread().getName());
}
}
class Animal implements Runnable{
public void run(){
System.out.println(Thread.currentThread().getName());
System.out.println("hello");
}
}