This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Instance variables and multi-threading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Instance variables and multi-threading" Watch "Instance variables and multi-threading" New topic

Instance variables and multi-threading

Paulus Maessen

Joined: Sep 29, 2004
Posts: 12
Hi all,

I have a question about the example in the SCWCD exam study kit:

On page 165, listing 10.7 shows a servlet that uses an instance variable to cache a database connection. As I understand it this is not threadsafe.

Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Yep, instance variables are *never* threadsafe.

SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
I agree. Here's the link:
subject: Instance variables and multi-threading
Similar Threads
Question about inheritance
Help with recursion
Servlet instances
Is final variable i:final int i=0;on stack or heap?