Java program for Runnable interface
KW.java
class KW implements Runnable { public void run() { System.out.println("Thread Running..."); } public static void main(String args[]) { KW k=new KW(); Thread t1=new Thread(k); //t1.run(); System.out.println(t1.isAlive()); t1.start(); System.out.println(t1.isAlive()); } }
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW false true Thread Running... kodingwindow@kw:~$
Comments and Reactions
What Next?
Java program for getName(), getId() and getPriority() methods
Java program for join() and sleep() methods
Java program for priority thread
Advertisement