• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SingleThreadModel Deprecated

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
As per servlet 2.4, the SingleThreadModel is now deprecated. THen, how to make a Servlet thread-safe.

Dhansumaal
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Concurrency and thread-safety are big subjects that can't be dealt with appropriately in a forum post. I suggest you start reading the Sun Java Tutorial on that subject.

Fundamentally, you need to guard access to shared, mutable state (and I realize that you may not understand what that means before you dig deeper into the subject).
Shared means anything that can be accessed from more than a single thread - in a web app, that would by servlet instance variables, session contents, context parameters, amongst other things.
Mutable means that the value can change. It's no problem to have shared data if its value never changes (maybe initialization parameters). But anything that can have its value/data changed is a problem.

Any read or write access to shared, mutable state -which also includes databases and files- needs to be protected through one of the various means described in the tutorial, e.g. synchronization.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to code for it. For example, do dot declare variables that are shared accross requests, such as instance variables.
 
reply
    Bookmark Topic Watch Topic
  • New Topic