diff --git a/Technology/SemaphoreDemo/.gitignore b/Technology/SemaphoreDemo/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Technology/SemaphoreDemo/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Technology/SemaphoreDemo/src/ProCon.java b/Technology/SemaphoreDemo/src/ProCon.java index f168a81..213c41c 100644 --- a/Technology/SemaphoreDemo/src/ProCon.java +++ b/Technology/SemaphoreDemo/src/ProCon.java @@ -1,5 +1,15 @@ -// java program to demonstrate -// use of semaphores Locks +// Karsten Jeppesen, UCN +// +// java application to demonstrate +// use of semaphores (Locks) +// +// Semaphore methods: +// acquire() +// will wait for semaphore to be in released state. Will set semaphore to acquired state +// release() +// will release an acquired semaphore + + import java.util.concurrent.*; //A shared resource/class. diff --git a/Technology/SemaphoreDemo/src/SemaphoreDemo.java b/Technology/SemaphoreDemo/src/SemaphoreDemo.java index 7b05c13..3712c44 100644 --- a/Technology/SemaphoreDemo/src/SemaphoreDemo.java +++ b/Technology/SemaphoreDemo/src/SemaphoreDemo.java @@ -1,5 +1,8 @@ -// java program to demonstrate -// use of semaphores Locks +// Karsten Jeppesen, UCN +// +// java application to demonstrate +// use of semaphores (Locks) + import java.util.concurrent.*; @@ -14,9 +17,7 @@ public class SemaphoreDemo // A 0 means that you are not allowed to read (as nobody has yet written to the buffer) Semaphore semCon = new Semaphore(0); - // creating two threads with name A and B - // Note that thread A will increment the count - // and thread B will decrement the count + // creating two threads named "Producer" and "Consumer" MyThread mt1 = new MyThread(semPro, semCon, "Producer"); MyThread mt2 = new MyThread(semPro, semCon, "Consumer"); diff --git a/Technology/ThreadsDemo/.gitignore b/Technology/ThreadsDemo/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Technology/ThreadsDemo/.gitignore @@ -0,0 +1 @@ +/bin/