Kaleeswaran Karuppasamy wrote:i know servlet not threadsafe i am asking doget and dopost method is thread safe or not
Hun ....... What do you mean by thread-safety??? It is said that servlets are not thread safe that means if there are 10 Simultaneous requests for a particular servlet the container will simply invoke ten different threads who will invoke the service method(in turn do get and doPost) of the Servlet (Unless your servlet implements the Threadsafe interface).
Please be aware of the fact that Variables local to methods are always threadsafe that means each Thread gets its own copy of the Method-Local variables. Now the so called Threadsafety problem occurs when you are using a Member variable i.e. the variable you declare in the servlet class all methods and all Threads share these variables.Change done by one method or one thread will be seen to everyone. So if you are using this for inter-method or inter-thread communication its ok but if you accidental use it for
(Cliched Example -->) something like The Balance in a Bank Account where one thread is Depositing while the other is Withdrawing all hell break loose.
Hope that helps.
Joined: Jul 19, 2007
this what i expected local variable are always thread safe...thank you