Results 1 to 1 of 1
Thread: Using threads
-
Using threads
Threads are very useful in programming practices. If used sensibly, they can solve complex problems easily. Following is an interesting example of threads.
Java Code:public class SimpleThread extends Thread { private int countDown = 5; private static int threadCount = 0; public SimpleThread() { super("" + ++threadCount); // Store the thread name start(); } public String toString() { return "#" + getName() + ": " + countDown; } public void run() { while(true) { System.out.println(this); if(--countDown == 0) return; } } public static void main(String[] args) { for(int i = 0; i < 5; i++) new SimpleThread(); } }
Similar Threads
-
How to use Java threads
By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:30 PM -
applets & threads
By willemjav in forum Java AppletsReplies: 2Last Post: 04-04-2008, 06:59 AM -
Threads
By one198 in forum Threads and SynchronizationReplies: 1Last Post: 11-20-2007, 06:15 PM -
Server n threads
By ferosh in forum NetworkingReplies: 2Last Post: 04-28-2007, 10:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks