Re: PRIVATE VARIABLES WITHIN PUBLIC CLASS
Chris Pratt <[email protected]> Mon, 6 Feb 2006 12:51:53 -0800
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_1934_6356397.1139259113414 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline No private is an access modifier, not a replication or synchronization keyword. All that it means is that only the specific class can access the data (not the specific instance). You have to remember that Servlets use a single instance of your servlet class to serve all the requests that come in. Often those requests will come in at the same time and you'll have multiple threads running through a single instance of your servlet. Anything on the stack (i.e. method local variables and arguments) are inherently threadsafe, anything else you must explicitly synchronize yourself. (*Chris*) On 2/6/06, vcragain <[email protected]> wrote: > > Hi - > Can someone please de-confuse me - If I have a public servlet class, with > ONLY private variables, how could the data get overlaid - isnt private > data > supposed to be owned by the specific object ONLY ? > Since we just invoke the servlet via the html - is there only 1 instance > of > the code ie 1 object invoked...therefore whoever he is referenced by last= , > owns his data ? > > > _________________________________________________________________________= __ > To unsubscribe, send email to [email protected] and include in the > body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > ___________________________________________________________________________ To unsubscribe, send email to [email protected] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ------=_Part_1934_6356397.1139259113414 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline No private is an access modifier, not a replication or synchronization keyw= ord. All that it means is that only the specific class can access the= data (not the specific instance). You have to remember that Servlets= use a single instance of your servlet class to serve all the requests that= come in. Often those requests will come in at the same time and you'= ll have multiple threads running through a single instance of your servlet.= Anything on the stack ( i.e. method local variables and arguments) are inherently threadsafe,= anything else you must explicitly synchronize yourself.<br> (*Chris*= )<br><br><div><span class=3D"gmail_quote">On 2/6/06, <b class=3D"gmail_send= ername">vcragain </b> <<a href=3D"mailto:[email protected]">[email protected]</a>> w= rote:</span><blockquote class=3D"gmail_quote" style=3D"border-left: 1px sol= id rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi -<= br> Can someone please de-confuse me - If I have a public servlet class, with<b= r>ONLY private variables, how could the data get overlaid - isnt private da= ta<br>supposed to be owned by the specific object ONLY ?<br>Since we just i= nvoke the servlet via the html - is there only 1 instance of <br>the code ie 1 object invoked...therefore whoever he is referenced by la= st,<br>owns his data ?<br><br>_____________________________________________= ______________________________<br>To unsubscribe, send email to <a href=3D"= mailto:[email protected]"> [email protected]</a> and include in the body<br>of the message "s= ignoff SERVLET-INTEREST".<br><br>Archives: <a href=3D"http://archives.= java.sun.com/archives/servlet-interest.html">http://archives.java.sun.com/a= rchives/servlet-interest.html </a><br>Resources: <a href=3D"http://java.sun.com/products/servlet/external= -resources.html">http://java.sun.com/products/servlet/external-resources.ht= ml</a><br>LISTSERV Help: <a href=3D"http://www.lsoft.com/manuals/user/user.= html"> http://www.lsoft.com/manuals/user/user.html</a><br></blockquote></div><br> ___________________________________________________________________________ To unsubscribe, send email to [email protected] and include in the body of the message "signoff SERVLET-INTEREST". <p> Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html <p> ------=_Part_1934_6356397.1139259113414--