Created
October 28, 2018 16:35
-
-
Save slmanju/42962b2998dd85a16d6cdafad9f713c8 to your computer and use it in GitHub Desktop.
multithreading with java
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 Concurrent { | |
public static void main(String[] args) { | |
Thread runner1 = new Thread(new ThreadRunner("R1")); | |
Thread runner2 = new Thread(new ThreadRunner("R2")); | |
runner1.start(); | |
runner2.start(); | |
} | |
} | |
class ThreadRunner implements Runnable { | |
private String name; | |
ThreadRunner(String name) { | |
this.name = name; | |
} | |
public void run() { | |
for (int i = 0; i < 10; ++i) { | |
System.out.printf("Name: %s %d %n", this.name, i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment