Implements Runnable Example Program in Java

By | December 25, 2010
You can get Java code for Java Implements Runnable in thread concept with example program.
You can get Java code for Java Implements Runnable in thread concept with example program.
class PrintRunnable implements Runnable {
public PrintRunnable(){
System.out.println(“New Thread started”);
new Thread(this).start();
}
public void run() {
for (int i = 0; i < 50; i++) {
System.out.print(i+”  “);
}
}
}
public class ImplementRunnable2 {
public static void main(String args[]) {
new PrintRunnable ();
new PrintRunnable ();
}
}
Result:
New Thread started
New Thread started
0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49

Leave a Reply

Your email address will not be published. Required fields are marked *