ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Multithreading with C#
Subject:   Hrmm...
Date:   2001-09-25 06:02:50
From:   andersdahlberg
" public static Object locker = ...
public static int x = 1;


public static void increment() {
synchronized( locker ) {
x = x + 1;


}


}
"


should be replaced with


public static int x = 1;
public static synchronized void increment() {
x = x + 1;
}


as it is otherwise not guarranted to work as expected when multiple threads are involved (lookup articles on javaworld.com and postings in comp.lang.java.programmer if you don't believe me...