- #1
twoski
- 181
- 2
Homework Statement
I have to write a simple program that uses threads to execute a queue of arbitrary tasks.
The more threads i make, the better it should perform (theoretically).
I have to simulate a thread pool without using any of Java's built in utilities for threads.
The Attempt at a Solution
My current attempt seems to work if i use only 3 threads. If i increase the number of threads, i end up getting exceptions caused by threads trying to access an empty queue.
How can i make my threads safely access the queue? I assume i need to do something with locks or somesuch.
I am also not sure what implementing a thread pool means. Is it sufficient to just store all my threads in some sort of list then call join() on all of them?
Here is relevant code: http://pastebin.com/Cbj64t4k
Last edited by a moderator: