Problem 01: Thread: Create Thread: by Extending Thread Class With Sleep Method
Problem 01: Thread: Create Thread: by Extending Thread Class With Sleep Method
package threadexamp;
}
System.out.println(i);
}
}
• Problem 02: Thread : Create thread by extending Thread class for comparing with problem 3
@Override
public void run()
{
System.out.println("Run method executed by child Thread");
t1.start();
System.out.println("Main method executed by main thread");
}
}
Problem 04: Thread : Create thread by implementing Runnable interface for comparing with Problem 03
where run() executing following thread rule(main() method will be executed first then others). But in
Problem 04 run() executing in normal sequence also run() executing following thread rule when passing
object through thread.
class Test implements Runnable {
@Override
public void run()
{
System.out.println("Run method executed by child Thread");
}
public static void main(String[] args)
{
t2.start();
t3.start();
}
}
Problem 06: Thread : Create thread and use join() method
t2.start();
t3.start();
}
}