• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

isThreadSafe question

 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
isThreadSafe = false means that the servlet can't handle multiple requests at the same time. so what happens actually??
is it run sequentially for each request or new servlets instances are created for each request? i read this kind of thing here
is this decision is determined differently in each servlet environment?
regards
maulin.
 
Srini Admala
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isThreadSafe = false indicates that the generated servlet for your jsp implements SingelThreadModel interface ---> only one request is handled at any time, so code is thread safe.
Either the incoming requests are serialized in some form and one request is handled at a time OR
you can have multiple instances of the same servlet each handling one request at a time.
-Srini
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srini,
so is it in programmer's hand to do something like that? how can i do it? do i need some kind scheduling mechanism for that like we can design for servers who handles multiple clients?
regards
maulin.
 
Srini Admala
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you implement SingleThreadModel interface, the container takes care of scheduling the requests and your code will be thread safe.
But it may not be good idea to go for it for scalability reasons. Instead snychronise the access code for shared resources.
-Srini
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Srini. i got it.
regards
maulin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic