Skip to content

Instantly share code, notes, and snippets.

@shaik2many
Created November 7, 2014 17:21
Show Gist options
  • Save shaik2many/1f1ce4650b28354a78a3 to your computer and use it in GitHub Desktop.
Save shaik2many/1f1ce4650b28354a78a3 to your computer and use it in GitHub Desktop.
java threading
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