Java Thread Program Using Runnable Interface

Posted by megahacker136 on October 19, 2008

public class soalan4 {

public static void main(String[] args) {
try {
Thread thread1 = new Thread(new runThread(“Parent Thread”));
Thread thread2 = new Thread(new runThread(“Child Thread”));
thread1.start();
thread2.start();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

class runThread implements Runnable {

String threadName;

runThread(String nama) {
threadName = nama;
}

public void run() {
for (int i = 1; i <= 5; i++) {
System.out.println(threadName + ” “ + i);
}
}
}

Download source code:

>>>DOWNLOAD<<<

This entry was posted on October 19, 2008 at 10:05 am and is filed under Open Source, Programing. Tagged: computer, Open Source, programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Comments
Advertisements
Zimbio Entertainment
Copyright © 2012 - Zimbio, Inc. Some rights reserved. Coming soon: Livingly
Share
. . .
Follow
. . .