Oops!  Good point!   Should be:

synchronized( this) {
    count++;
    out.println( count);
}

Cheers!
Mark

----- Original Message -----
From: "James Wilson" <[EMAIL PROTECTED]>
Sent: Friday, April 20, 2001 8:17 PM


> Am I correct in assuming that both
>
> count++;
>
> and
>
> System.out.println(count);
>
> need to be synchronized in order to guarantee that the right
request prints
> the right value of count?
>
> -----Original Message-----
> Saumont Pierre-Yves
> Sent: Friday, April 20, 2001 5:15 PM
>
> Hey Mark, why do you need to use init() when you can do :
>
> import java.io.*;
> import javax.servlet.http.*;
> import javax.servlet.*;
>
> public class CounterCons extends HttpServlet {
>         int count = 1122;
>         public void doGet(HttpServletRequest
req,HttpServletResponse res)
> throws
> IOException {
>                 PrintWriter out=res.getWriter();
>                 count++;
>                 out.println(count);
>         }
> }
>
> That's not exactly the same, but it's probably close enough to
what he
> want's !
>
> BTW, Mark, how is your mail program configured ? Replies to
your messages
> are sent to you and not to the list. May be that's why you get
so many
> private questions !
>
> Pierre-Yves

___________________________________________________________________________
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

Reply via email to