In which way Servlet implements multiThread without servlet implement Run

Hi,

In which way Servlet implements multiThread without servlet implement Runnable.

In general servletconaainer use one instance of servlet to handle multiple request(except implement SingleThreadmodal).

Ithing that conatainer can achive this ,in this Way

Myservlet ms;

1st Way:

For each new request container call

new Thread(){

puvlic void run(){

ms.service(request,response);

}

}.start();

but I do not thing in this way we get any performace.

It is better creat pool of Myservelt. and get object from this

ms1,ms2,ms3

2nd way is

Myservlet implement Runnable

and for each request

new Myservlet ().start();

Please tell me In which way conatiner achive multithread of servlet

Siddharth Singh(singhsiddh@yahoo.com)

[863 byte] By [Siddhartha] at [2007-10-3 5:22:51]
«« RTTI
»» RTTI
# 1
You don't need to do any of this. The servlet container starts its own threads, and they call the servlet methods as required. All you have to do is syncrhonize your servlet internally as required to protect anything that needs protecting from multiple threads.
ejpa at 2007-7-14 23:29:55 > top of Java-index,Java Essentials,Java Programming...
# 2
I am intrested due to curious.I know all thing what you are mention.siddharth Singh
Siddhartha at 2007-7-14 23:29:55 > top of Java-index,Java Essentials,Java Programming...
# 3
Why don't you go and look at the Tomcat source for instance? It won't be easy to find, but I don't think it matters much anyway, because the exact implementation might vary from container to container. I doubt it's specified.
CeciNEstPasUnProgrammeura at 2007-7-14 23:29:55 > top of Java-index,Java Essentials,Java Programming...
# 4
Without actually looking at the Servlet API I'm certain that it mandates your alternative #1.
ejpa at 2007-7-14 23:29:55 > top of Java-index,Java Essentials,Java Programming...