17.5
Rules about Locks
THREADS AND LOCKS
be separated in time, with other actions coming between them. Consequently, if
two threads concurrently assign distinct values to the same shared non 
volatile
double
 or
long
 variable, a subsequent use of that variable may obtain a value that
is not equal to either of the assigned values, but some implementation dependent
mixture of the two values.
An implementation is free to implement
load
,
store
,
read
, and
write
 actions
for
double
 and
long
 values as atomic 64 bit actions; in fact, this is strongly
encouraged. The model divides them into 32 bit halves for the sake of several cur 
rently popular microprocessors that fail to provide efficient atomic memory trans 
actions on 64 bit quantities. It would have been simpler for Java to define all
memory transactions on single variables as atomic; this more complex definition
is a pragmatic concession to current hardware practice. In the future this conces 
sion may be eliminated. Meanwhile, programmers are cautioned always to explic 
itly synchronize access to shared
double
 and
long
 variables.
17.5   Rules about Locks
By the pricking of my thumbs,
Something wicked this way comes.
Open, locks,
Whoever knocks!
 William Shakespeare,
 Macbeth
, Act IV, scene i
Let
T
 be a thread and
L
 be a lock. There are certain constraints on the actions per 
formed by
T
 with respect to
L
:
A
lock
 action by
T
 on
L
 may occur only if, for every thread
S
 other than
T
, the
number of preceding
unlock
 actions by
S
 on
L
 equals the number of preceding
lock
 actions by
S
 on
L
. (Less formally: only one thread at a time is permitted
to lay claim to a lock, and moreover a thread may acquire the same lock mul 
tiple times and doesn't relinquish ownership of it until a matching number of
unlock
 actions have been performed.)
An
unlock
 action by thread
T
 on lock
L
 may occur only if the number of pre 
ceding
unlock
 actions by
T
 on
L
 is strictly less than the number of preceding
lock
 actions by
T
 on
L
. (Less formally: a thread is not permitted to unlock a
lock it doesn't own.)
With respect to a lock, the
lock
 and
unlock
 actions performed by all the
threads are performed in some total sequential order. This total order must be con 
sistent with the total order on the actions of each thread.
406






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved