Guest User

Untitled

a guest
Feb 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class ThreadDemoWithRunnable {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. myStart();
  6. }
  7.  
  8. public static void myStart(){
  9. Thread t = new Thread(new MyThread1());
  10. Thread t1 = new Thread(new MyThread1());
  11. // t.run();
  12. t.start();
  13. t1.start();
  14.  
  15. Thread t2 = new Thread();
  16. t2.start();
  17. // t.start();
  18. }
  19.  
  20.  
  21.  
  22. }
  23.  
  24. class MyThread1 implements Runnable{
  25.  
  26. @Override
  27. public void run() {
  28. for(int i =0;i<10;i++)
  29. {
  30. System.out.println(Thread.currentThread()+" Value "+i);
  31.  
  32. }
  33. }
  34.  
  35. }
Add Comment
Please, Sign In to add comment