Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /**
  2. * Created by Пётр on 04.10.15.
  3. */
  4. public class Threads1 {
  5. public static MyThread t = new MyThread();
  6. static String message = "inside main ";
  7.  
  8. public static void main(String a[]) throws Exception {
  9. t.start();
  10. for (int i = 0; i < 10; i++) {
  11. System.out.println(message + i);
  12. sleep();
  13. }
  14. }
  15.  
  16. static class MyThread extends Thread {
  17. String message = "inside MyThread ";
  18.  
  19. public void run() {
  20. for (int i = 0; i < 10; i++) {
  21. System.out.println(message + i);
  22. Solution.sleep();
  23. }
  24. }
  25. }
  26.  
  27. public static void sleep() {
  28. try {
  29. Thread.sleep(10);
  30. } catch (InterruptedException e) {
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement