DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=37356>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=37356 ------- Additional Comments From [EMAIL PROTECTED] 2006-03-10 11:15 ------- Proposed patch: in org.apache.catalina.session.StandardSession line 284 (tomcat 5.0.28) /** * The access count for this session. */ protected transient int accessCount = 0; has to be replaced by /** * The access count for this session. */ protected volatile transient int accessCount = 0; Explanation: The expression accessCount++ is not thread-safe because each thread may hold a local copy of the variable which does not have to be synchronized with main memory immediately. The volatile keyword forces this synchronization. See the discussion on http://forum.java.sun.com/thread.jspa?threadID=604831&start=30&tstart=0 [quote] 2) Local vs. main mem: Threads have--or can have--their own local copies of shared variables. When T1 writes a value to a variable, if the variable is not volatile and there's no syncing, that new value may live only in T1's local copy and may never get written to main mem, which means other threads may never see that new value. Entering and leaving sync blocks forces a reconciliation between the thread's local memory and main mem. Declaring a variable volatile forces every read and write of that variable to go to main mem. [end quote] Another solution would be to synchronize the code segments. I have to apologize for my claim that ++ and -- were atomic for int datatypes. This seems to be only true for single-CPU systems (without hyperThreading). -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]