Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java static variable in cluster environment

Designing J2EE Applications for Real-Life Clustered Environments

this article said cannot use java static variable in cluster environment, but if we want to use the static variable like feature (only one copy of value shared by all object in a clustered application) what should we use?

like image 439
user1169587 Avatar asked Jan 31 '13 10:01

user1169587


1 Answers

A static variable can only be accesed by one Java Virtual Machine, loaded with one class loader. If you need to share this value to several JVM, you can use a database, a cache (memcached, redis), or any other external system.

like image 121
greuze Avatar answered Sep 29 '22 06:09

greuze