Hi Mike,

Yup, that was my perception of the implications of static variables, just never crossed my mind that each instance runs in a separate VM. So yes, my heart is broken... Database procedures it is.

Terrracotta and class sharing don't seem like the right way to do this.

Thanks all,
Florijan

In Java, static variables are unique per-class-per-class-loader. That is, if you have the same class loaded in two separate class loaders, they will have independent static variables. Likewise, obviously, if you run two JVM's, the static variables will not be shared. WO instances each run in their own JVM's, completely unshared (well, as far as you're concerned at the level you're writing code). You can NOT count on static variables sharing across instances. You can only count on static variables being available in a SINGLE instance, and even then only in a SINGLE class loader (though it just so happens that your entire app is loaded in a single class loader, so that part isn't going to get you). If you're counting on two instances of WO sharing a static variable, you better start preparing yourself now, because you're about to have your heart broken. If you need unique IDs across instances, there are several techniques, but the least pain is to just use sequence generators from your database and let the database handle the concurrency and synchronization.

On Feb 28, 2007, at 9:32 PM, Florijan Stamenkovic wrote:

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to