RockAndRoll
RockAndRoll

Reputation: 2277

How does jsp ensure thread safety?

When multiple threads are accessing the same servlet instance,how is it possible that we get expected results always.Since when one thread starts exceuting,it can set some value to instance variable that a different running thread can access. There in no lock on object. Can anybody throw some light how it is happening and we are getting expected results each time??

Thanks in advance

Upvotes: 2

Views: 163

Answers (2)

Dave Newton
Dave Newton

Reputation: 160191

It doesn't ensure thread safety: instance variables must be managed by the programmer.

In general you don't really want to do that, and generally don't need to.

Upvotes: 1

Grim
Grim

Reputation: 1976

JSP will not ensure thread safety by the technology. You must code the threadsafety in the JSP yourself.

Sometimes the container implements thread-safety under special conditions, by technology: if one port for only one request without multiplex and without portredirection.

Upvotes: 2

Related Questions