On Wed, 19 Sep 2001, Graham, Billy wrote:
> Thanks to all!
>
> As requested by a few people, I was just about to send a sample of my
> 'dodgy' code when I read an e-mail suggesting I use a 'Protected' doGet()
> method. I tried this but it didn't work - however it did remind me about the
> 'Synchronized' keyword (as I stated earlier, I am new to java but have read
> extensively on it - so somewhere in the basement of my brain the facts are
> there). I made the doGet() method both Synchronized and Protected and Hey
> Presto! everything works - no more dodgy variables. I still don't quite
> understand what was changing the variables as there was only one request
> being made to the server for the servlet, though as I outlined in an earlier
> e-mail the server feedback seemed to indicate there were 2 Get() requests
> being made. Anyway - it's working A OK now, so I'm off for a coffee!
Well, when you get back from your coffee break, I suggest you start
taking a closer look at your code and try to find a better solution,
because this isn't really a good one. If using synchronized on the
method solved your problem, then it is a threading-related issue. But
synchronizing the entire method is like using a chain-saw when a
scalpel is what's really needed. Basically, it could cause a
significant performance degradation. You need to find more
specifically where the threading issue is, and reduce it as much as
possible; eliminating it would be best, but if you can't, make it as
small as possible and put a synchronized around just that block. I
haven't been following this thread that closely, so I don't have
particular suggestions, but it seems some people suggesting checking
whether you're using instance variables or not.
FWIW, protected shouldn't have anything to do with this, it just
controls what subclasses/packages have access to the method. I
suspect all your code is in the one class, and you won't be
subclassing it, so it's not really going to affect anything (probably
you should remove it).
Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]
___________________________________________________________________________
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