Use stderr where appropriate.
[TD_SR.git] / TD1 / exo2 / Main.java
CommitLineData
7e42d822
JB
1class Main {
2
3 public static void main(String[] args) {
3c1259ec 4 final int THREADS_NUMBER = 3;
7e42d822
JB
5 Thread t[] = new Thread[THREADS_NUMBER];
6
06566a55
JB
7 for (int i = 0; i < t.length; i++) {
8 ThreadJob threadJob = new ThreadJob(String.valueOf(i));
9 t[i] = new Thread(threadJob);
7e42d822
JB
10 t[i].start();
11 }
12
06566a55 13 for (int i = 0; i < t.length; i++) {
7e42d822
JB
14 try {
15 t[i].join();
16 }
17 catch (InterruptedException e) {
06566a55 18 // this part is executed when an exception (in this example InterruptedException) occurs
ce28a021 19 System.err.println("InterruptedException: " + e);
7e42d822
JB
20 }
21 }
22 System.out.println("Threads execution finished");
23 }
24
25}