Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Web Component Certification (OCEJWCD)
Context/Session Thread safety
Greg Lamonakis
Greenhorn
Posts: 4
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can anyone tell me if these two code snippets do the same thing and if not what the specific difference is:
synchronize(getServletContext()) {
....
}
compared to
ServletContext mySC = getServletContext();
synchronize(mySC) {
.....
}
And is the answer the same for synchronizing on sessions (I would assume so but want to be sure) as listed below:
synchronize(getSession()) {
.......
}
HttpSession mySession = getSession();
synchronize (mySession) {
...........
}
Thanks for your time,
Greg
ritesh hk
Greenhorn
Posts: 6
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I dont see any difference there. You could
test
it out buddy. It should be fine I guess. In both cases the same object is beign referenced.
-Ritesh
-------------<br />SCJP 1.4 <br />SCWCD (just started)
James Christian
Ranch Hand
Posts: 63
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The only difference is that in the first your reference to the context expires at the end of your synchronised code block. But I don't see how knowing this or not knowing it would help or deter you in the exam.
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question ID : 995377945515
synchronize(getServletContext())
Reading parameters from web.xml
Synchronizing getServletContext
mock question , wrong answer
More...