Created
April 12, 2014 07:26
-
-
Save rajeevprasanna/10522963 to your computer and use it in GitHub Desktop.
This file contains 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
class MyRunnable implements Runnable { | |
public void run() { | |
System.out.println("Important job running in MyRunnable"); | |
} | |
} |
This file contains 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 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); | |
} | |
} |
This file contains 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 Test { | |
public static void main(String[] args) { | |
System.out.println("testing threads"); | |
} | |
} |
This file contains 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 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