Why java.util.concurrent.LinkedBlockingQueuehas a link headand tailhow not volatile?
java.util.concurrent.LinkedBlockingQueue
head
tail
volatile
Any change in heador tailin one thread may not be visible to another thread, so will this lead to problems?
headand tailwill be protected putLockor takeLock. As long as your synchronization is appropriate, you do not need to declare fields as volatile.
putLock
takeLock
So, to answer your question. Fields should not be volatileif they are correctly synchronized (they are).
, , , , .
: , .
: , .. - synchronized {} . synchronized {} .
synchronized {}
, volatile - , - , volatile , . , , .
-, volatile . , . SO - .
, , volatile - , , type - , . , , .
Source: https://habr.com/ru/post/1657282/More articles:Count true objects in an array - ruby | fooobar.comWhen does the flex-grow switch become flexible and vice versa? - cssКак вы привязываете прядильщик Dropdown к родительскому Linlingayout? - androidAlternative for looping with "dynamic" variables with R - for-loopCMake: CMakeLists for C11 - c11Running a custom shell script using CMake - cmakeHow to create a procedure like SetLength, which also has zeros in memory? - initializationhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1657285/node-js-inserting-array-of-objects-to-mysql-database-when-using-transactions&usg=ALkJrhiGbDrc4F8v4pm7PbL_FZxMX82QzQTypeScript + React: correctly defining default parameters - javascriptChoosing one row over another - sqlAll Articles