Saturday, May 8, 2010

Java Basics # 002

 

Case :

Let’s handle concurrency while dealing with collections in of-course a multi-threaded environment. Vector is the chosen one here. Now the system is in action and a couple of threads are accessing the same Vector.

Q. Thread A and Thread B call different methods on the Vector? Any issues?

2 comments:

  1. Vector is thread safe. It's a synchronized object. So update operations are guaranteed to be atomic. However be ready for a ConcurrentModificationException

    ReplyDelete
  2. What if I am not using the iterator dished out by this Vector?

    ReplyDelete

Google Analytics - Active