Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 2
メインメモリ上の値を参照するvolatile | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 17
メインメモリ上の値を参照するvolatile
変数宣言時に volatile int i; というようにvolatileという修飾子をつけて宣言することができます。

javaでは、必ずしもメインメモリ上の値を見るわけではなく、メインメモリ上の値を、スレッドのキャッシュエリアにコピーしてその値を使用する場合があります。
しかしこれではメインメモリを見たスレッドと、スレッドのキャッシュエリアのコピーを使用して、値を変更した場合、メインメモリ上で値が一致しなくなってしまいます。
このような矛盾がおきないように、スレッドが参照する変数に volatile 修飾子をつけることにより、 必ずメインメモリ上を見に行く ようになります。

メインメモリ上の値を参照するvolatile
メインメモリ上の値を参照するvolatile

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 60

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 60

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 69

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/thread/volatile/volatile.html on line 69