Results 1 to 1 of 1
-
Creating a Thread using the Runnable interface
This example shows how to create a Thread by implementing the Runnable interface.
Java Code:public class RunnableThread implements Runnable { private int countDown = 5; public String toString() { return "#" + Thread.currentThread().getName() + ": " + countDown; } public void run() { while(true) { System.out.println(this); if(--countDown == 0) return; } } public static void main(String[] args) { for(int i = 1; i <= 5; i++) new Thread(new RunnableThread(), "" + i).start(); // Output is like SimpleThread.java } }Last edited by Java Tip; 04-09-2008 at 06:34 PM.
Similar Threads
-
data from the main/GUI thread to another runnin thread...
By cornercuttin in forum Threads and SynchronizationReplies: 2Last Post: 04-23-2008, 10:30 PM -
Error : Runnable did not complete within 10000ms
By piyushgpt1 in forum Advanced JavaReplies: 1Last Post: 02-05-2008, 07:04 PM -
If JNI thread call the java object in another thread, it will crash.
By skaterxu in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 07:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks