Skip to content

Instantly share code, notes, and snippets.

@rajeevprasanna
Created April 12, 2014 07:26
Show Gist options
  • Save rajeevprasanna/10522963 to your computer and use it in GitHub Desktop.
Save rajeevprasanna/10522963 to your computer and use it in GitHub Desktop.
class MyRunnable implements Runnable {
public void run() {
System.out.println("Important job running in MyRunnable");
}
}
public class MyThread {
public void run() {
System.out.println("Important job running in MyThread");
}
// you're free to overload the run()method in your Thread subclass
// The overloaded run(String s) method will be ignored by the Thread class
// unless you call it yourself. The Thread class expects a run() method with
// no arguments, and it will execute this method for you in a separate call
// stack after the thread has been started
public void run(String s) {
System.out.println("String in run is " + s);
}
}
public class Test {
public static void main(String[] args) {
System.out.println("testing threads");
}
}
public class TestThreads {
public static void main(String[] args) {
MyRunnable r = new MyRunnable();
Thread foo = new Thread(r);
Thread bar = new Thread(r);
Thread bat = new Thread(r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment