Commit cfd3e0fb authored by sahar.moalla's avatar sahar.moalla

ThreadSync

parent 22286ac1
...@@ -37,7 +37,7 @@ public class SynchronizedQueue<T> { ...@@ -37,7 +37,7 @@ public class SynchronizedQueue<T> {
while (queue.isEmpty()) { while (queue.isEmpty()) {
wait(); wait();
} }
notifyAll();
// Remove and return the element from the queue // Remove and return the element from the queue
return queue.poll(); return queue.poll();
} }
......
...@@ -3,10 +3,10 @@ public class ThreadPoolMain { ...@@ -3,10 +3,10 @@ public class ThreadPoolMain {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Create a thread pool with 3 threads and a maximum of 10 tasks // Create a thread pool with 3 threads and a maximum of 10 tasks
ThreadPool threadPool = new ThreadPool(3, 10); ThreadPool threadPool = new ThreadPool(3, 100);
// Execute 10 tasks // Execute 10 tasks
for(int i=0; i<10; i++) { for(int i=0; i<1000; i++) {
int taskNo = i; int taskNo = i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment