Use stderr where appropriate.
[TD_SR.git] / TD1 / exo2 / Main.java
index d28e6b3b5402f0b1b8b8cc9dcc24813ad6e13de7..5ad851b78c8e0d16c9e96b889055c431b0c6a9ae 100644 (file)
@@ -2,21 +2,21 @@ 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.err.println("InterruptedException: " + e);
             }
         }
         System.out.println("Threads execution finished");