Advertisement
Guest User

1

a guest
Nov 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1.  
  2. public class Main {
  3.  
  4. public static void main(String[] args) {
  5. Thread[] threads = new Thread[10];
  6. for ( int i = 0; i<10; i++)
  7. {
  8. threads[i] = new Thread(new Fib(),"Thread" + i);
  9. }
  10. for (Thread thread : threads)
  11. {
  12. thread.start();
  13. try
  14. {
  15. thread.join(); // wait for the threads to terminate
  16. }
  17. catch (InterruptedException e)
  18. {
  19. e.printStackTrace();
  20. }
  21. }
  22.  
  23. //System.out.println("Thread "+ fib.getName() + " started.");
  24. System.out.println();
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement