Yeah I sort of assumed it was as well. Do any Servlet Implementations (such as JRun) synchronize their implementation of the HttpSession interface? it would probably be very easy to just declare the hashtable for the attributes as synchronized. The same for the ServletContext/application implementation?
_____________________________________________ Pete Freitag ([EMAIL PROTECTED]) CTO, CFDEV.COM ColdFusion Developer Resources http://www.cfdev.com/ -----Original Message----- From: Drew Falkman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 5:25 PM To: JRun-Talk Subject: RE: Do application variables need locking? That's a good question - I actually thought that it was for a while. I do know that synchronization basically kills the ability to scale. It's single threaded... -Drew Falkman Author, JRun Web Application Construction Kit http://www.drewfalkman.com/books/0789726009/ -----Original Message----- From: Pete Freitag [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 2:26 PM To: JRun-Talk Subject: RE: Do application variables need locking? Drew, Why isn't the session object (HttpSession) just synchronized in the servlet API? I can't think of a reason why it shouldn't be (performance?). _____________________________________________ Pete Freitag ([EMAIL PROTECTED]) CTO, CFDEV.COM ColdFusion Developer Resources http://www.cfdev.com/ -----Original Message----- From: Drew Falkman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 4:49 PM To: JRun-Talk Subject: RE: Do application variables need locking? Hey Nick- In Java, to protect session and application variables from multithreading issues, you need to use synchronization. A good way to do this is to use JavaBeans components to store your session and application data. Then within your bean, you can use the synchronized keyword to synchronize your objects and methods. For example, if you have a bean called ShoppingCart which stores a users shopping cart information in an object called cartItems with an add() method, you could do this: synchronized (cartItems) { cartItems.add(item,price) } The key is that you want to synchronize your object when you make changes (just as you would do with cflock). Beans allows you to do this fairly easily. Then just store the bean in application or session scope. -Drew Falkman Author, JRun Web Application Construction Kit http://www.drewfalkman.com/books/0789726009/ -----Original Message----- From: Nick de Voil [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 12:19 PM To: JRun-Talk Subject: Do application variables need locking? In ColdFusion, an application variable needs to be locked while it's being accessed, to prevent one user writing to it when another is reading, giving indeterminate results or worse. Do we need to do something similar with JRun? I want to keep a set of application parameters in an application object for reading frequently by many pages, but I also want to have a feature allowing these parameters to be changed. Thanks Nick ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
