google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

polish error in example doc #273

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
http://docs.google.com/View?docid=dd2fhx4z_5df5hw8
in this page in the counting example, the count instance var should be
volatile for the example to work.

@SessionScoped
public class Counter {

  volatile int count = 0;

  /** Increments the count and returns the new value. */
  public synchronized int increment() {
    return count++;
  }
}

Original issue reported on code.google.com by nrayn...@gmail.com on 16 Nov 2008 at 1:50

GoogleCodeExporter commented 9 years ago
the increment method is synchronized, so we're safe.

Original comment by limpbizkit on 30 Dec 2008 at 11:44

GoogleCodeExporter commented 9 years ago
After A bit of re-reading the JLS, you are right. Sorry for the inconvenience.

Original comment by nrayn...@gmail.com on 31 Dec 2008 at 8:39