Add exo1 code.
[TD_SR.git] / TD1 / exo2 / Main.java
diff --git a/TD1/exo2/Main.java b/TD1/exo2/Main.java
new file mode 100644 (file)
index 0000000..d28e6b3
--- /dev/null
@@ -0,0 +1,25 @@
+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]);
+             t[i].start();
+         }
+
+         for (int i = 0; i < threadArray.length; i++) {
+            try {
+                t[i].join();
+            }
+            catch (InterruptedException e) {
+             // this part is executed when an exception (in this example InterruptedException) occurs
+            }
+        }
+        System.out.println("Threads execution finished");
+    }
+
+}