| Author |
Static variable
|
rex tony
Ranch Hand
Joined: Aug 29, 2007
Posts: 159
|
|
|
Static variable Is Thread Safe?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
|
No, static variables are not automatically thread-safe. You'll have to take care of synchronization if you have multiple threads that are accessing a static variable simultaneously.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
camelia codarcea
Ranch Hand
Joined: May 08, 2007
Posts: 36
|
|
Hello, Static variable should be changed inside static syncronised methods in order to be thread-safe. Two threads that access a static syncronized method, will always block each other, regardless if they are using the same instance or two different instances.
|
SCJP 5.0 .... 97%
|
 |
 |
|
|
subject: Static variable
|
|
|