Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class TwoThreads {
  2. public static class ThreadAB implements Runnable
  3. {
  4. String s;
  5. private ThreadAB(String string)
  6. {
  7. this.s = string;
  8. }
  9.  
  10. public void run()
  11. {
  12. System.out.println(s);
  13. }
  14.  
  15.  
  16. }
  17.  
  18.  
  19.  
  20. public static void main(String[] args) {
  21. Runnable run1 = new ThreadAB("A" + "\n" + "B");
  22. Runnable run2 = new ThreadAB("1" + "\n" + "2");
  23. Thread Thread1 = new Thread(run1);
  24. Thread Thread2 = new Thread(run2);
  25. Thread1.start();
  26. Thread2.start();
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement