Advertisement
Guest User

thread

a guest
May 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class DretveLoop {
  4.  
  5. char chr = 'A';
  6. int N = 10;
  7.  
  8. class MojaDretva implements Runnable
  9. {
  10. public void run(){
  11. for(int i = 0; i < N; i++){
  12. System.out.println("Thread "
  13. +Thread.currentThread().getName()+ ": " + i);
  14. }
  15.  
  16. }
  17. }
  18. DretveLoop()
  19. {
  20. for(int i = 0; i < N; i++)
  21. {
  22. MojaDretva tlc = new MojaDretva();
  23. Thread t = new Thread(tlc);
  24. t.setName("T" + chr++);
  25. t.start();
  26. System.out.println("Thread Stanje " + t.getName() + ": " + t.getState());
  27. }
  28.  
  29. }
  30. public static void main(String[] args) {
  31. new DretveLoop();
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement