https://issues.apache.org/bugzilla/show_bug.cgi?id=49972
--- Comment #2 from konstantin.s.serebry...@gmail.com 2010-09-22 09:56:49 EDT --- It looks scarier than that. In short, see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html Case1: Thread1 executes: long now = System.currentTimeMillis(); if ((now - currentDateGenerated) > 1000) { synchronized (format) { if ((now - currentDateGenerated) > 1000) { currentDateGenerated = now; Thread2 executes: long now = System.currentTimeMillis(); if ((now - currentDateGenerated) > 1000) { Thread2 skips the "if" part. If these were the first calls to this function the return value in Thread2 will be null. ----- Case2: Thread1 executes: currentDate = format.format(new Date(now)); Thread2 goes through fast path and executes return currentDate; The object currentDate was not properly published and according to the Java memory model (if I understand it correctly) may be incomplete. Of course, in practice you will not see any problem in 99.9% of the cases. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org