× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Dan

You may have already read it but I thought I'd mention that The Java language 
specifications has a chapter on Threads and Locks that
may help. I keep all my variables local in the doGet method of my servlets.  
I'm assuming that is safe, right?

ftp://ftp.javasoft.com/docs/specs/langspec-2.0.pdf

Thanx, PLA

-----Original Message-----
From: java400-l-admin@midrange.com
[mailto:java400-l-admin@midrange.com]On Behalf Of Eyers, Daniel
Sent: Wednesday, April 17, 2002 3:03 PM
To: 'java400-l@midrange.com'
Subject: RE: Thread safe instance variables



Actually, I was looking at Java in general, although I have an immediate need 
of JSP/Servlets.  I visualize
classes/objects as being sort of variables on steroids; each class that 
implements other classes has it's own copy of
the class/object in the scope of the instantiating class.  As a learn more 
about java, that model breaks down,
especially with containers like WAS and Tomcat.  Apparently, they all share the 
code (and can share the instance
variables with static).  Since local variables are not shared, I can use them 
without concern.

My simple model (above) breaks down really fast in discussions of threads and 
thread-safe coding.  I'm still trying to
grasp the concept of sharing code with other requests.  If a change an instance 
variable that is *not* a static, it
seems to me (with my meager understanding of Java) that it changes for that 
particular instantiation of the object.
However, the need to make things thread-safe seems to contradict that 
assumption.

My hope is that if I understand this point, I can better comprehend threads 
which is a huge leap for me (*lots* of
procedural language (RPG, COBOL, BASIC, PASCAL, etc.) experience. This 
multi-threaded stuff reminds me of why I didn't
become an electrical engineer).

I guess I'm looking for two things.  One, why is there a need for thread-safe 
techniques (the web sites I have read
really don't do a good job of telling me why, even Sun's site) and Two, how to 
best combat this situation in the context
of JSP/servlet technology.

Clear as mud?

dan

<snip>
I think I made the assumption that Daniel is talking about
Servlets, where it makes sense to avoid synchronization and
not Swing.
<snip>
_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) 
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.