This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Any request to the servlet will spawn a new thread a separate copy of a servlet will be running is that true ? If so what if i have a syncrhonized block in a servlets doGet() which does some lengthy operation , will it block any other request to this servlet until i leave the sync block ? or is it just for that servlets request for that user ? I need your help on this , thanks. Val.
"Any request to the servlet will spawn a new thread a separate copy of a servlet will be running is that true ?" NO - the same copy of the servlet object will be shared by all Threads. That is why you must be very carefull about using instance variables - they are visible to all Threads. If you can't figure out a way to share a resource, you can synchronize access. Synchronizing the entire method is safest. If you synchronize a block, be sure to synchronize on an object that is visible to all Threads - synchronizing on a local object is useless. Bill