From 9a1582110b81fbb23df78dceadca8289a4ccd1bf Mon Sep 17 00:00:00 2001 From: civitarese Date: Thu, 2 Apr 2020 16:54:26 +0200 Subject: [PATCH] all the code under src folder --- {esempioJoin => src/join}/Main.java | 3 +++ {esempioJoin => src/join}/MyThread.java | 2 ++ {producerConsumer => src/producerConsumer}/Consumer.java | 2 ++ {producerConsumer => src/producerConsumer}/Main.java | 2 ++ {producerConsumer => src/producerConsumer}/Producer.java | 2 ++ {producerConsumer => src/producerConsumer}/Queue.java | 2 ++ .../producerConsumerUnsynced}/Consumer.java | 2 ++ .../producerConsumerUnsynced}/Main.java | 2 ++ .../producerConsumerUnsynced}/Producer.java | 2 ++ .../producerConsumerUnsynced}/Queue.java | 2 ++ {semaphore => src/semaphore}/Main.java | 3 ++- {semaphore => src/semaphore}/MyThread.java | 2 ++ {semaphore => src/semaphore}/Semaphore.java | 4 ++-- {semaphoreAPI => src/semaphoreAPI}/Main.java | 2 ++ {semaphoreAPI => src/semaphoreAPI}/MyThread.java | 2 ++ 15 files changed, 31 insertions(+), 3 deletions(-) rename {esempioJoin => src/join}/Main.java (97%) rename {esempioJoin => src/join}/MyThread.java (96%) rename {producerConsumer => src/producerConsumer}/Consumer.java (92%) rename {producerConsumer => src/producerConsumer}/Main.java (93%) rename {producerConsumer => src/producerConsumer}/Producer.java (95%) rename {producerConsumer => src/producerConsumer}/Queue.java (94%) rename {producerConsumerUnsynced => src/producerConsumerUnsynced}/Consumer.java (90%) rename {producerConsumerUnsynced => src/producerConsumerUnsynced}/Main.java (88%) rename {producerConsumerUnsynced => src/producerConsumerUnsynced}/Producer.java (94%) rename {producerConsumerUnsynced => src/producerConsumerUnsynced}/Queue.java (93%) rename {semaphore => src/semaphore}/Main.java (92%) rename {semaphore => src/semaphore}/MyThread.java (97%) rename {semaphore => src/semaphore}/Semaphore.java (87%) rename {semaphoreAPI => src/semaphoreAPI}/Main.java (96%) rename {semaphoreAPI => src/semaphoreAPI}/MyThread.java (97%) diff --git a/esempioJoin/Main.java b/src/join/Main.java similarity index 97% rename from esempioJoin/Main.java rename to src/join/Main.java index e72fbbf..14157f3 100755 --- a/esempioJoin/Main.java +++ b/src/join/Main.java @@ -1,3 +1,5 @@ +package join; + import java.util.ArrayList; import java.util.Random; @@ -22,6 +24,7 @@ public class Main { for (Thread t : threads) { t.join(); } + System.out.println("...All thread finished!"); } diff --git a/esempioJoin/MyThread.java b/src/join/MyThread.java similarity index 96% rename from esempioJoin/MyThread.java rename to src/join/MyThread.java index 3316d3a..3c12a83 100755 --- a/esempioJoin/MyThread.java +++ b/src/join/MyThread.java @@ -1,3 +1,5 @@ +package join; + import java.util.Random; public class MyThread extends Thread { diff --git a/producerConsumer/Consumer.java b/src/producerConsumer/Consumer.java similarity index 92% rename from producerConsumer/Consumer.java rename to src/producerConsumer/Consumer.java index 69a30fd..794b2b8 100644 --- a/producerConsumer/Consumer.java +++ b/src/producerConsumer/Consumer.java @@ -1,3 +1,5 @@ +package producerConsumer; + public class Consumer implements Runnable { private final Queue queue; diff --git a/producerConsumer/Main.java b/src/producerConsumer/Main.java similarity index 93% rename from producerConsumer/Main.java rename to src/producerConsumer/Main.java index 0d260c4..1466609 100644 --- a/producerConsumer/Main.java +++ b/src/producerConsumer/Main.java @@ -1,3 +1,5 @@ +package producerConsumer; + public class Main { public static void main(String[] args) { Queue q = new Queue(); diff --git a/producerConsumer/Producer.java b/src/producerConsumer/Producer.java similarity index 95% rename from producerConsumer/Producer.java rename to src/producerConsumer/Producer.java index ccb0234..7984871 100644 --- a/producerConsumer/Producer.java +++ b/src/producerConsumer/Producer.java @@ -1,3 +1,5 @@ +package producerConsumer; + public class Producer implements Runnable { private final String id; diff --git a/producerConsumer/Queue.java b/src/producerConsumer/Queue.java similarity index 94% rename from producerConsumer/Queue.java rename to src/producerConsumer/Queue.java index 45a678d..500a131 100644 --- a/producerConsumer/Queue.java +++ b/src/producerConsumer/Queue.java @@ -1,3 +1,5 @@ +package producerConsumer; + import java.util.ArrayList; public class Queue { diff --git a/producerConsumerUnsynced/Consumer.java b/src/producerConsumerUnsynced/Consumer.java similarity index 90% rename from producerConsumerUnsynced/Consumer.java rename to src/producerConsumerUnsynced/Consumer.java index 678475c..c9d3c1d 100644 --- a/producerConsumerUnsynced/Consumer.java +++ b/src/producerConsumerUnsynced/Consumer.java @@ -1,3 +1,5 @@ +package producerConsumerUnsynced; + public class Consumer implements Runnable { private final Queue queue; diff --git a/producerConsumerUnsynced/Main.java b/src/producerConsumerUnsynced/Main.java similarity index 88% rename from producerConsumerUnsynced/Main.java rename to src/producerConsumerUnsynced/Main.java index 28c8c03..2f40290 100644 --- a/producerConsumerUnsynced/Main.java +++ b/src/producerConsumerUnsynced/Main.java @@ -1,3 +1,5 @@ +package producerConsumerUnsynced; + public class Main { public static void main(String[] args) { Queue q = new Queue(); diff --git a/producerConsumerUnsynced/Producer.java b/src/producerConsumerUnsynced/Producer.java similarity index 94% rename from producerConsumerUnsynced/Producer.java rename to src/producerConsumerUnsynced/Producer.java index 73f672e..88dcd33 100644 --- a/producerConsumerUnsynced/Producer.java +++ b/src/producerConsumerUnsynced/Producer.java @@ -1,3 +1,5 @@ +package producerConsumerUnsynced; + public class Producer implements Runnable { private final String id; diff --git a/producerConsumerUnsynced/Queue.java b/src/producerConsumerUnsynced/Queue.java similarity index 93% rename from producerConsumerUnsynced/Queue.java rename to src/producerConsumerUnsynced/Queue.java index 430089a..7c923d1 100644 --- a/producerConsumerUnsynced/Queue.java +++ b/src/producerConsumerUnsynced/Queue.java @@ -1,3 +1,5 @@ +package producerConsumerUnsynced; + import java.util.ArrayList; //Esempio di coda condivisa che non usa wait e notify diff --git a/semaphore/Main.java b/src/semaphore/Main.java similarity index 92% rename from semaphore/Main.java rename to src/semaphore/Main.java index 8fd988c..7e8de14 100755 --- a/semaphore/Main.java +++ b/src/semaphore/Main.java @@ -1,7 +1,8 @@ +package semaphore; + import java.util.ArrayList; import java.util.Random; -//Utilizzo di un semaforo "fatto a " public class Main { public static void main(String arg[]) throws Exception { Random r = new Random(); diff --git a/semaphore/MyThread.java b/src/semaphore/MyThread.java similarity index 97% rename from semaphore/MyThread.java rename to src/semaphore/MyThread.java index 7446f03..80841e7 100755 --- a/semaphore/MyThread.java +++ b/src/semaphore/MyThread.java @@ -1,3 +1,5 @@ +package semaphore; + import java.util.Random; public class MyThread extends Thread { diff --git a/semaphore/Semaphore.java b/src/semaphore/Semaphore.java similarity index 87% rename from semaphore/Semaphore.java rename to src/semaphore/Semaphore.java index 1ca3407..a6ea59d 100755 --- a/semaphore/Semaphore.java +++ b/src/semaphore/Semaphore.java @@ -1,7 +1,7 @@ -//Classe che implementa tramite wait e notify un Semaforo. +package semaphore;//Classe che implementa tramite wait e notify un Semaforo. //Se non vi ricordate cosa sia un semaforo, google is your best friend. -public class Semaphore extends Thread { +public class Semaphore { private int maxNumber; //numero massimo di thread private int threadsIn; //conteggio dei thread nell'area critica diff --git a/semaphoreAPI/Main.java b/src/semaphoreAPI/Main.java similarity index 96% rename from semaphoreAPI/Main.java rename to src/semaphoreAPI/Main.java index f8b3a59..cbaee26 100755 --- a/semaphoreAPI/Main.java +++ b/src/semaphoreAPI/Main.java @@ -1,3 +1,5 @@ +package semaphoreAPI; + import java.util.Random; import java.util.Vector; import java.util.concurrent.Semaphore; diff --git a/semaphoreAPI/MyThread.java b/src/semaphoreAPI/MyThread.java similarity index 97% rename from semaphoreAPI/MyThread.java rename to src/semaphoreAPI/MyThread.java index c889268..12ca0ce 100755 --- a/semaphoreAPI/MyThread.java +++ b/src/semaphoreAPI/MyThread.java @@ -1,3 +1,5 @@ +package semaphoreAPI; + import java.util.Random; import java.util.concurrent.Semaphore; -- 2.18.1