Created
November 7, 2014 17:21
-
-
Save shaik2many/1f1ce4650b28354a78a3 to your computer and use it in GitHub Desktop.
java threading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestThread { | |
public static void main(String[] args) { | |
String[] workitems = {"Quran", "Coummnity Service", "Teaching", "Business"}; | |
for (String name : workitems) { | |
new Thread(new DoWork(name)).start(); | |
} | |
System.out.println("Done...."); | |
} | |
} | |
public class DoWork implements Runnable { | |
private String name; | |
public DoWork(String name) { | |
this.name = name; | |
} | |
private void work(){ | |
for(int i=0; i<10000; i++); | |
System.out.println("Completed working on - "+name); | |
} | |
@Override | |
public void run() { | |
work(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment