I need some kind of a queue that will be synchronized for adding new elements and removing new elements:
You should use a BlockingQueue
(for example ArrayBlockingQueue
) which takes care of all of the synchronization for you. You call queue.add(...)
to add to the queue and another thread would call take()
to remove items from the queue.