I have a java class with a non-finite int variable that I explicitly initialized in the constructor to 0. All other variable calls are controlled by ReentrantLock. Should I worry that the threads will not see the initial value of 0, because I did not use the lock in the constructor?
Yes, you have to worry. To avoid problems in this case, you need to securely publish an object reference.
From Java Concurrency in practice :
, , . :;volatile AtomicReference;;, .
, , . :
() , new (- ).
new
, , 0 , , , (JLS ยง17.4.4):
0
(, ) - . , ,
Java Concurrency :
, , , .
, . "-". , , Concurrency. . .
, :
, . :;volatile field AtomicReference;;. , " ".
, . :
;
volatile field AtomicReference;
. , " ".
, , , (, , LinkedBlockingQueue ..).
, int ( 64- , long) , , "" , - - . , ( , , , , , ).
int
long
, , 0, .