The procedure is as follows:
Class ThreadDemo1 implements runnable{//implements Runnable interface private string name;private int time;public ThreadDemo1 (String name , int time) {this.name=name;this.time=time;} public void Run () {//Overwrite the Run method try {thread.sleep (this.time)} catch (Interruptedexception e) {//TODO auto-generated catch bl Ocke.printstacktrace ();} System.out.println (this.name+ "thread hibernation" +this.time);}} public class MyThread {public static void main (string[] args) {ThreadDemo1 thread01=new ThreadDemo1 ("A", 1000);// Implement Runnable sub-class object; ThreadDemo1 thread02=new ThreadDemo1 ("B", 2000); ThreadDemo1 thread03=new ThreadDemo1 ("C", "N"), new Thread (THREAD01). Start ();//Instantiate the thread class, and start threading new Thread (THREAD02). Start (); new Thread (THREAD03). Start ();}}
Run as follows:
A thread hibernation 1000
B Thread Hibernation 2000
C Thread Hibernation 3000
Java thread Start (implement Runnable interface)