X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD1%2Fexo2%2FMain.java;h=f44796019d37fa664cd3e2ff426b094b85a84665;hb=3c1259eca93334f9f93bd14879606e8d16e5927a;hp=d28e6b3b5402f0b1b8b8cc9dcc24813ad6e13de7;hpb=7e42d822cf647a90586c45a7b2f5c649f8f81cb9;p=TD_SR.git diff --git a/TD1/exo2/Main.java b/TD1/exo2/Main.java index d28e6b3..f447960 100644 --- a/TD1/exo2/Main.java +++ b/TD1/exo2/Main.java @@ -2,21 +2,20 @@ class Main { public static void main(String[] args) { final int THREADS_NUMBER = 3; - ExThread threadArray[] = new ExThread[THREADS_NUMBER]; Thread t[] = new Thread[THREADS_NUMBER]; - for (int i = 0; i < threadArray.length; i++) { - threadArray[i] = new ExThread(String.valueOf(i)); - t[i] = new Thread(threadArray[i]); + for (int i = 0; i < t.length; i++) { + ThreadJob threadJob = new ThreadJob(String.valueOf(i)); + t[i] = new Thread(threadJob); t[i].start(); } - for (int i = 0; i < threadArray.length; i++) { + for (int i = 0; i < t.length; i++) { try { t[i].join(); } catch (InterruptedException e) { - // this part is executed when an exception (in this example InterruptedException) occurs + // this part is executed when an exception (in this example InterruptedException) occurs } } System.out.println("Threads execution finished");