aun_ee

aun_ee

  • NA
  • 7
  • 0

Synchronizing Two Threads

Mar 24 2005 7:31 PM
I have two threads sharing an Arraylist. Thread 1 adds an object to the arraylist whereas thread 2 reads and remove the object from the array list. I want to synchronize them such that, whenever thread 1 has something to add to the list it should get full control of the arraylist and not have to wait for any lock ,whereas thread 2 can read and remove data from the list whenever thread 1 is not using it annd should unlock it as soon as thread 1 gets a data to write. Any ideas what will be a good technique to implement it? Thanks,

Answers (3)