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



______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to