Hi singlethread interface problem from Hanuman Deshmukh book at page 160, it says that: "The specification guarantees that if a servlet implements this interface, the container will not execute the service() method in more than one thread simultaneously." I understand this is why it is OK for sample at page 161 based on above statement. but I am not clear the following word from Hanuman Deshmukh book at page 160. To avoid the performance problem, a servlet container may create multiple instance of the servlet class. In short, multiple requests will still be processed simultaneously but by different servlet instance. I dont think the container whose singlethread interface implemented by this algrithm will make the sample code at page 161 works fine. The reason seems simple, two instances(evevn they are different) can not wirte any information in to the same files simultaneously . Please help me, Thanks,
posted 13 years ago
Frank, Please note there is a static variable instanceNumber declared in listing 10.3 to keep track different file name for each instance instanitated by container. (so no conflict here).. In fact, if you reading down after listing 10.3 you will see the description about this static variable. HTH
not so smart guy still curious to learn new stuff every now and then
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads