TD1: Cleanup the exo1 code.
[TD_SR.git] / TD1 / exo2 / Main.java
CommitLineData
7e42d822
JB
1class Main {
2
3 public static void main(String[] args) {
06566a55 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
7e42d822
JB
19 }
20 }
21 System.out.println("Threads execution finished");
22 }
23
24}