I suspect this post is going to be one of the first in a series of my criticisms of the Java interview book by K. Arulkumaran.
In the Java Fundamentals Question 15 he asks about the difference between ArrayList and a Vector, and HashMap and Hashtable, and stack and a queue. He then proceeds to ask which is better -- the thread safe version or not thread safe version.
Mr. Arulkumaran then offers an answer that would make the candidate fail an interview with me:
When I saw this I felt like calling up the author and saying "Wrong!"
Here is why. What makes the author so smart as to know that as a general rule his application won't be multithreaded ? What does it even mean to "temporarily synchronize" ? In the same book he talks about servlets, EJBs, RMI, messaging, etc. Application servers can take your presumably single threaded application and load-balance the heck out of it -- your single-threaded application may end up running across different CPUs, different network nodes, you name it.
My answer would be this -- as a general rule do not assume that your application will be single-threaded. In modern JVMs obtaining locks is so cheap that it makes it insignificant. Assuming single-threaded execution is dangerous and will make it extremely difficult to scale your application. Most developers have such a mediocre grasp of the overall big picture of the system that giving them the freedom to default to unsynchronized code is just plainly irresponsible.
This is just one of the many inconsistencies in this book. Good book if you want something to yell about on your blog -- bad book if you want to use it as a guide to get a job or to hire a candidate.