volatile.html 87.2 KB
Newer Older
沉默王二's avatar
沉默王二 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
<!DOCTYPE html>
<html lang="zh-CN" data-theme="light">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="generator" content="VuePress 2.0.0-beta.46" />
    <meta name="theme" content="VuePress Theme Hope" />
    <meta property="og:url" content="https://tobebetterjavaer.com/thread/volatile.html"><meta property="og:site_name" content="Java 程序员进阶之路"><meta property="og:title" content="Java并发编程volatile关键字解析"><meta property="og:type" content="article"><meta property="og:updated_time" content="2022-05-12T08:24:21.000Z"><meta property="og:locale" content="zh-CN"><meta property="article:tag" content="Java"><meta property="article:modified_time" content="2022-05-12T08:24:21.000Z"><script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?5230ac143650bf5eb3c14f3fb9b1d3ec";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
      </script><link rel="stylesheet" href="//at.alicdn.com/t/font_3180624_7cy10l7jqqh.css"><link rel="icon" href="/favicon.ico"><link rel="icon" href="/assets/icon/chrome-mask-512.png" type="image/png" sizes="512x512"><link rel="icon" href="/assets/icon/chrome-mask-192.png" type="image/png" sizes="192x192"><link rel="icon" href="/assets/icon/chrome-512.png" type="image/png" sizes="512x512"><link rel="icon" href="/assets/icon/chrome-192.png" type="image/png" sizes="192x192"><link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"><meta name="theme-color" content="#46bd87"><link rel="apple-touch-icon" href="/assets/icon/apple-icon-152.png"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="msapplication-TileImage" content="/assets/icon/ms-icon-144.png"><meta name="msapplication-TileColor" content="#ffffff"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"><title>Java并发编程volatile关键字解析 | Java 程序员进阶之路</title><meta name="description" content="一份通俗易懂、风趣幽默的Java学习指南,内容涵盖Java基础、Java并发编程、Java虚拟机、Java企业级开发、Java面试等核心知识点。学Java,就认准Java程序员进阶之路">
    <style>
      :root {
        --bg-color: #fff;
      }

      html[data-theme="dark"] {
        --bg-color: #1d2025;
      }

      html,
      body {
        background-color: var(--bg-color);
      }
    </style>
    <script>
      const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
      const systemDarkMode =
        window.matchMedia &&
        window.matchMedia("(prefers-color-scheme: dark)").matches;

      if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
        document.querySelector("html").setAttribute("data-theme", "dark");
      }
    </script>
    <link rel="stylesheet" href="/assets/style.598c3f8b.css">
    <link rel="modulepreload" href="/assets/app.795d54da.js"><link rel="modulepreload" href="/assets/volatile.html.bfbcfd5c.js"><link rel="modulepreload" href="/assets/plugin-vue_export-helper.21dcd24c.js"><link rel="modulepreload" href="/assets/volatile.html.26279f7f.js"><link rel="prefetch" href="/assets/index.html.dfcf8f59.js"><link rel="prefetch" href="/assets/home.html.08023af3.js"><link rel="prefetch" href="/assets/array.html.77525f56.js"><link rel="prefetch" href="/assets/print.html.6fe8360d.js"><link rel="prefetch" href="/assets/bzhan-10wan.html.98f8ba37.js"><link rel="prefetch" href="/assets/csdn-1000wan.html.438218cb.js"><link rel="prefetch" href="/assets/index.html.a4bb5c6e.js"><link rel="prefetch" href="/assets/zhihu-1000wan.html.4bf2b6f4.js"><link rel="prefetch" href="/assets/basic-data-type.html.6be3e7e2.js"><link rel="prefetch" href="/assets/flow-control.html.f6c60ead.js"><link rel="prefetch" href="/assets/javadoc.html.b34e8efb.js"><link rel="prefetch" href="/assets/operator.html.9431d9fc.js"><link rel="prefetch" href="/assets/java-basic-34.html.70be78f8.js"><link rel="prefetch" href="/assets/java-basic.html.52bd7f06.js"><link rel="prefetch" href="/assets/java-thread.html.4a99fb0e.js"><link rel="prefetch" href="/assets/jvm.html.1b4e3107.js"><link rel="prefetch" href="/assets/beijing.html.5436f34b.js"><link rel="prefetch" href="/assets/chengdu.html.09b27f2f.js"><link rel="prefetch" href="/assets/guangzhou.html.ce1033cd.js"><link rel="prefetch" href="/assets/hangzhou.html.9719a0ea.js"><link rel="prefetch" href="/assets/nanjing.html.0381e4b6.js"><link rel="prefetch" href="/assets/qingdao.html.026cf757.js"><link rel="prefetch" href="/assets/shenzhen.html.037e48a5.js"><link rel="prefetch" href="/assets/suzhou.html.1f658a4a.js"><link rel="prefetch" href="/assets/xian.html.4a14941e.js"><link rel="prefetch" href="/assets/zhengzhou.html.43c30f38.js"><link rel="prefetch" href="/assets/48-keywords.html.e76832ee.js"><link rel="prefetch" href="/assets/Overriding.html.14f830f8.js"><link rel="prefetch" href="/assets/annotation.html.14064668.js"><link rel="prefetch" href="/assets/box.html.54cc70a2.js"><link rel="prefetch" href="/assets/class-object.html.c43412d3.js"><link rel="prefetch" href="/assets/comparable-omparator.html.397dc2ff.js"><link rel="prefetch" href="/assets/deep-copy.html.b367f078.js"><link rel="prefetch" href="/assets/enum.html.21e74b14.js"><link rel="prefetch" href="/assets/equals-hashcode.html.cd3210fa.js"><link rel="prefetch" href="/assets/fanshe.html.13ada7e7.js"><link rel="prefetch" href="/assets/generic.html.7ec41e80.js"><link rel="prefetch" href="/assets/hashcode.html.24290486.js"><link rel="prefetch" href="/assets/immutable.html.ed5b1443.js"><link rel="prefetch" href="/assets/instanceof-jvm.html.845ed78f.js"><link rel="prefetch" href="/assets/int-cache.html.0d30900e.js"><link rel="prefetch" href="/assets/java-naming.html.de2604a0.js"><link rel="prefetch" href="/assets/java-unicode.html.9e4e93b1.js"><link rel="prefetch" href="/assets/jdk-while-for-wuxian-xunhuan.html.e352d875.js"><link rel="prefetch" href="/assets/jdk9-char-byte-string.html.e81be44e.js"><link rel="prefetch" href="/assets/override-overload.html.f7d74176.js"><link rel="prefetch" href="/assets/pass-by-value.html.e26c3cdc.js"><link rel="prefetch" href="/assets/true-generic.html.ce09d792.js"><link rel="prefetch" href="/assets/varables.html.6a80fc0e.js"><link rel="prefetch" href="/assets/arraylist.html.0dcdca73.js"><link rel="prefetch" href="/assets/fail-fast.html.4b8a884f.js"><link rel="prefetch" href="/assets/gailan.html.87d77185.js"><link rel="prefetch" href="/assets/hashmap-interview.html.307a5634.js"><link rel="prefetch" href="/assets/hashmap.html.abe56333.js"><link rel="prefetch" href="/assets/iterator-iterable.html.967b5cf7.js"><link rel="prefetch" href="/assets/linkedlist.html.8ede144e.js"><link rel="prefetch" href="/assets/list-war-2.html.b8fa44fb.js"><link rel="prefetch" href="/assets/arrays.html.7944f961.js"><link rel="prefetch" href="/assets/collections.html.2e6479a3.js"><link rel="prefetch" href="/assets/guava.html.e73aaedd.js"><link rel="prefetch" href="/assets/hutool.html.06e72427.js"><link rel="prefetch" href="/assets/os.html.5e6a959a.js"><link rel="prefetch" href="/assets/wangluo.html.b41cb57f.js"><link rel="prefetch" href="/assets/bat-shuati.html.adba9635.js"><link rel="prefetch" href="/assets/history.html.2b0daef2.js"><link rel="prefetch" href="/assets/java.html.c5bee727.js"><link rel="prefetch" href="/assets/jianli.html.75854f37.js"><link rel="prefetch" href="/assets/learn-jianyi.html.1b72d4e2.js"><link rel="prefetch" href="/assets/nicearticle.html.b56e678a.js"><link rel="prefetch" href="/assets/pdf.html.a28195f1.js"><link rel="prefetch" href="/assets/progit.html.3b6ba984.js"><link rel="prefetch" href="/assets/yuanyifeng-c-language.html.1d18c5bc.js"><link rel="prefetch" href="/assets/rumen.html.9cc17590.js"><link rel="prefetch" href="/assets/gailan.html.fee068f9.js"><link rel="prefetch" href="/assets/npe.html.a94a2b73.js"><link rel="prefetch" href="/assets/shijian.html.0924a1ec.js"><link rel="prefetch" href="/assets/try-with-resouces.html.8dcef913.js"><link rel="prefetch" href="/assets/git-qiyuan.html.a341e213.js"><link rel="prefetch" href="/assets/progit.html.a119468c.js"><link rel="prefetch" href="/assets/Chocolatey-Homebrew.html.ad256880.js"><link rel="prefetch" href="/assets/DBeaver.html.75fbe8f6.js"><link rel="prefetch" href="/assets/chiner.html.13c55607.js"><link rel="prefetch" href="/assets/choco.html.f8923e81.js"><link rel="prefetch" href="/assets/fastjson.html.f97ae6fd.js"><link rel="prefetch" href="/assets/forest.html.79a7cfed.js"><link rel="prefetch" href="/assets/gson.html.e79a454d.js"><link rel="prefetch" href="/assets/jackson.html.ded110ad.js"><link rel="prefetch" href="/assets/junit.html.2436284c.js"><link rel="prefetch" href="/assets/knife4j.html.fe2f8e7d.js"><link rel="prefetch" href="/assets/log4j.html.14af993a.js"><link rel="prefetch" href="/assets/log4j2.html.9b5a6f13.js"><link rel="prefetch" href="/assets/logback.html.a9628274.js"><link rel="prefetch" href="/assets/others.html.ed8fcf05.js"><link rel="prefetch" href="/assets/slf4j.html.2fd3dca6.js"><link rel="prefetch" href="/assets/tabby.html.9fb65d66.js"><link rel="prefetch" href="/assets/warp.html.4380b228.js"><link rel="prefetch" href="/assets/4-debug-skill.html.9bd076fc.js"><link rel="prefetch" href="/assets/BIONIOAIO.html.ea89d11f.js"><link rel="prefetch" href="/assets/shangtou.html.dd79a90f.js"><link rel="prefetch" href="/assets/Lambda.html.997b367a.js"><link rel="prefetch" href="/assets/optional.html.23c0a140.js"><link rel="prefetch" href="/assets/stream.html.214aab27.js"><link rel="prefetch" href="/assets/asm.html.0e0abd8b.js"><link rel="prefetch" href="/assets/bytecode.html.ba8f00b6.js"><link rel="prefetch" href="/assets/class-file-jiegou.html.3dff0326.js"><link rel="prefetch" href="/assets/class-load.html.6a788fca.js"><link rel="prefetch" href="/assets/compile-jdk.html.531caac0.js"><link rel="prefetch" href="/assets/cpu-percent-100.html.f6bd745b.js"><link rel="prefetch" href="/assets/gc.html.cec6db87.js"><link rel="prefetch" href="/assets/how-jvm-run-zijiema-zhiling.html.400c699c.js"><link rel="prefetch" href="/assets/how-run-java-code.html.1867de4d.js"><link rel="prefetch" href="/assets/hsdb.html.e06d55d6.js"><link rel="prefetch" href="/assets/jit.html.a14bdfce.js"><link rel="prefetch" href="/assets/meituan-9-gc.html.f5a5b89a.js"><link rel="prefetch" href="/assets/neicun-jiegou.html.f0fca3bb.js"><link rel="prefetch" href="/assets/oom.html.23228526.js"><link rel="prefetch" href="/assets/problem-tools.html.fab08888.js"><link rel="prefetch" href="/assets/tujie-gc.html.ca2dffab.js"><link rel="prefetch" href="/assets/what-happen-when-javac.html.ab4282c1.js"><link rel="prefetch" href="/assets/what-is-jvm.html.5131a239.js"><link rel="prefetch" href="/assets/whereis-the-object.html.c695df3e.js"><link rel="prefetch" href="/assets/zijiema-zhiling.html.34c655bc.js"><link rel="prefetch" href="/assets/zongjie.html.c9e5e3c3.js"><link rel="prefetch" href="/assets/auto-generator.html.edd07e0d.js"><link rel="prefetch" href="/assets/index.html.fd879420.js"><link rel="prefetch" href="/assets/yuneban-wangyiyunyinyue.html.275a589e.js"><link rel="prefetch" href="/assets/waibao-1geyue.html.fbddc89c.js"><link rel="prefetch" href="/assets/yanjiusuo-20wan.html.76b660c5.js"><link rel="prefetch" href="/assets/maven.html.f0c8e738.js"><link rel="prefetch" href="/assets/redis12question.html.58f0e7e0.js"><link rel="prefetch" href="/assets/shanganaliyun.html.04eee07a.js"><link rel="prefetch" href="/assets/api-wangguan.html.c2b18262.js"><link rel="prefetch" href="/assets/rumen.html.28382740.js"><link rel="prefetch" href="/assets/100-budiushi.html.c3040dbf.js"><link rel="prefetch" href="/assets/rabbitmq-rumen.html.1f0066c6.js"><link rel="prefetch" href="/assets/deletedb-binlog-weiguanjishu.html.605b28a5.js"><link rel="prefetch" href="/assets/redis-shuju-yizhixing.html.0d2d7824.js"><link rel="prefetch" href="/assets/40-interview.html.2cb0fe6c.js"><link rel="prefetch" href="/assets/nginx.html.c9dd536d.js"><link rel="prefetch" href="/assets/BOKEYUANruhegaoxiaodixuexijishu.html.54dd2a4d.js"><link rel="prefetch" href="/assets/ZHIHUjavaxuexidaoshemechengduokeyizhaodiyifengongzuo.html.e4fead09.js"><link rel="prefetch" href="/assets/bokeyuan-jianxijavazhongdifangwenquanxiankongzhi.html.a78d6592.js"><link rel="prefetch" href="/assets/bokeyuan-ruhegaoxiaodixuexijishu.html.e9d4ca36.js"><link rel="prefetch" href="/assets/haibukuaiyongmybatisplusshoubashoujiaoni.html.4769ffdb.js"><link rel="prefetch" href="/assets/javaxuexidaoshemechengduokeyizhaodiyifengongzuo.html.3289a228.js"><link rel="prefetch" href="/assets/jiagoushizenyanghuizhijitongjiagoulantu.html.980a677a.js"><link rel="prefetch" href="/assets/jielehenduosihuodiganchu.html.0ffa8f43.js"><link rel="prefetch" href="/assets/jishuzongjianbeikaichuliao.html.1b7e52c1.js"><link rel="prefetch" href="/assets/weixin-zuixinbujiabandigongsimingdan.html.bf87a7d5.js"><link rel="prefetch" href="/assets/abstract.html.3094fdb5.js"><link rel="prefetch" href="/assets/code-init.html.70ef628a.js"><link rel="prefetch" href="/assets/construct.html.5ae3e6eb.js"><link rel="prefetch" href="/assets/final.html.c83d9074.js"><link rel="prefetch" href="/assets/inner-class.html.b8e81363.js"><link rel="prefetch" href="/assets/instanceof.html.d3be3510.js"><link rel="prefetch" href="/assets/interface.html.7833e904.js"><link rel="prefetch" href="/assets/method.html.4d951864.js"><link rel="prefetch" href="/assets/object-class.html.85420110.js"><link rel="prefetch" href="/assets/static.html.1a009c06.js"><link rel="prefetch" href="/assets/this-super.html.65fa5da3.js"><link rel="prefetch" href="/assets/var.html.7a0cfd0f.js"><link rel="prefetch" href="/assets/redis-springboot.html.5e59844d.js"><link rel="prefetch" href="/assets/rumen.html.e13dbda5.js"><link rel="prefetch" href="/assets/xuebeng-chuantou-jichuan.html.26ef04a3.js"><link rel="prefetch" href="/assets/hello-world.html.d0d5adf0.js"><link rel="prefetch" href="/assets/what-is-java.html.b724e432.js"><link rel="prefetch" href="/assets/image-yasuo.html.8853b749.js"><link rel="prefetch" href="/assets/log4j2.html.b3fd06a7.js"><link rel="prefetch" href="/assets/computer-base.html.f469b424.js"><link rel="prefetch" href="/assets/Filter-Interceptor-Listener.html.d4211e38.js"><link rel="prefetch" href="/assets/aop-log.html.390b071a.js"><link rel="prefetch" href="/assets/cors.html.b8f51585.js"><link rel="prefetch" href="/assets/initializr.html.ae05e8c2.js"><link rel="prefetch" href="/assets/ioc.html.1c4cca00.js"><link rel="prefetch" href="/assets/jpa.html.c4109873.js"><link rel="prefetch" href="/assets/jwt.html.b4f208bb.js"><link rel="prefetch" href="/assets/logback.html.65200f68.js"><link rel="prefetch" href="/assets/mysql-druid.html.bf232591.js"><link rel="prefetch" href="/assets/oss.html.977b34d5.js"><link rel="prefetch" href="/assets/springtask.html.406633ab.js"><link rel="prefetch" href="/assets/swagger.html.03ed15b7.js"><link rel="prefetch" href="/assets/thymeleaf.html.1a24ed99.js"><link rel="prefetch" href="/assets/tomcat.html.73ec3645.js"><link rel="prefetch" href="/assets/transaction.html.c6ea47a0.js"><link rel="prefetch" href="/assets/constant-pool.html.c79f5c21.js"><link rel="prefetch" href="/assets/equals.html.2fb94b25.js"><link rel="prefetch" href="/assets/immutable.html.36fadfba.js"><link rel="prefetch" href="/assets/intern.html.3d87fa6f.js"><link rel="prefetch" href="/assets/join.html.bb336f49.js"><link rel="prefetch" href="/assets/split.html.0ff2ce60.js"><link rel="prefetch" href="/assets/tobebetterjavaer-beian.html.3820089c.js"><link rel="prefetch" href="/assets/tobebetterjavaer-wangzhan-shangxian.html.a80895d2.js"><link rel="prefetch" href="/assets/tupian-zhuanlian.html.7ab13c07.js"><link rel="prefetch" href="/assets/BlockingQueue.html.9ccd9ba0.js"><link rel="prefetch" href="/assets/ConcurrentHashMap.html.e7f83c81.js"><link rel="prefetch" href="/assets/ConcurrentLinkedQueue.html.da4bfec1.js"><link rel="prefetch" href="/assets/CopyOnWriteArrayList.html.b8e564c2.js"><link rel="prefetch" href="/assets/CountDownLatch.html.f036fab2.js"><link rel="prefetch" href="/assets/LockSupport.html.c7d00cfa.js"><link rel="prefetch" href="/assets/ReentrantReadWriteLock.html.d1bd972f.js"><link rel="prefetch" href="/assets/ScheduledThreadPoolExecutor.html.8d668046.js"><link rel="prefetch" href="/assets/ThreadLocal.html.f9a6fed8.js"><link rel="prefetch" href="/assets/ali-executors.html.988adc8e.js"><link rel="prefetch" href="/assets/aqs.html.d6a8f5b4.js"><link rel="prefetch" href="/assets/atomic.html.93391f09.js"><link rel="prefetch" href="/assets/cas.html.4534d702.js"><link rel="prefetch" href="/assets/condition.html.a41bdc76.js"><link rel="prefetch" href="/assets/fork-join.html.f967d485.js"><link rel="prefetch" href="/assets/jmm.html.7be72db5.js"><link rel="prefetch" href="/assets/lock.html.5385ecc8.js"><link rel="prefetch" href="/assets/map.html.ae80f8e6.js"><link rel="prefetch" href="/assets/pool.html.1918e02b.js"><link rel="prefetch" href="/assets/reentrantLock.html.002f84e4.js"><link rel="prefetch" href="/assets/shengchanzhe-xiaofeizhe.html.0915b865.js"><link rel="prefetch" href="/assets/synchronized.html.6094d556.js"><link rel="prefetch" href="/assets/thread-bring-some-problem.html.c8ae3e7a.js"><link rel="prefetch" href="/assets/thread-group-and-thread-priority.html.873709ce.js"><link rel="prefetch" href="/assets/thread-state-and-method.html.70b8e2e8.js"><link rel="prefetch" href="/assets/wangzhe-thread.html.dda72253.js"><link rel="prefetch" href="/assets/why-need-thread.html.507a940d.js"><link rel="prefetch" href="/assets/electron-information-engineering.html.b3d4a3e7.js"><link rel="prefetch" href="/assets/read-csapp.html.23c82cf4.js"><link rel="prefetch" href="/assets/aliyun-shuaiguo-gongchengshi.html.e4346151.js"><link rel="prefetch" href="/assets/chadiansanhuo.html.e9cc0b99.js"><link rel="prefetch" href="/assets/chengxuyuannv-chonghui-java.html.b9de6702.js"><link rel="prefetch" href="/assets/daxue-nuli-jisuanji.html.2b1074e1.js"><link rel="prefetch" href="/assets/fumutuanju.html.577491d1.js"><link rel="prefetch" href="/assets/algorithm.html.1a85d3e4.js"><link rel="prefetch" href="/assets/c.html.13c84e14.js"><link rel="prefetch" href="/assets/ccc.html.dc46b7b7.js"><link rel="prefetch" href="/assets/go.html.3224a568.js"><link rel="prefetch" href="/assets/lanqiaobei.html.95c65e6d.js"><link rel="prefetch" href="/assets/os.html.b5e2df6b.js"><link rel="prefetch" href="/assets/python.html.8154391a.js"><link rel="prefetch" href="/assets/qianduan.html.72394ced.js"><link rel="prefetch" href="/assets/index.html.fe9dcc15.js"><link rel="prefetch" href="/assets/java-mianshi-zhinan.html.f1a349c4.js"><link rel="prefetch" href="/assets/index.html.af7b50d7.js"><link rel="prefetch" href="/assets/jibenjieshao.html.b8a08842.js"><link rel="prefetch" href="/assets/mysql.html.99fca397.js"><link rel="prefetch" href="/assets/collection.html.42c40509.js"><link rel="prefetch" href="/assets/javase.html.a4bff51b.js"><link rel="prefetch" href="/assets/javathread.html.1bcda474.js"><link rel="prefetch" href="/assets/jvm.html.dd68f45e.js"><link rel="prefetch" href="/assets/nixi.html.5cc39b1c.js"><link rel="prefetch" href="/assets/redis.html.b039ba47.js"><link rel="prefetch" href="/assets/spring.html.75b19ea2.js"><link rel="prefetch" href="/assets/jvm.html.498133d1.js"><link rel="prefetch" href="/assets/thread.html.30d3dabc.js"><link rel="prefetch" href="/assets/yitiaolong.html.5a2d99a5.js"><link rel="prefetch" href="/assets/404.html.e75684b7.js"><link rel="prefetch" href="/assets/index.html.0a5dd707.js"><link rel="prefetch" href="/assets/home.html.162e4f8a.js"><link rel="prefetch" href="/assets/array.html.1c028fd4.js"><link rel="prefetch" href="/assets/print.html.0e077cd0.js"><link rel="prefetch" href="/assets/bzhan-10wan.html.26cb7c84.js"><link rel="prefetch" href="/assets/csdn-1000wan.html.520963b5.js"><link rel="prefetch" href="/assets/index.html.ce2ec9fa.js"><link rel="prefetch" href="/assets/zhihu-1000wan.html.2f0670ea.js"><link rel="prefetch" href="/assets/basic-data-type.html.b08b1513.js"><link rel="prefetch" href="/assets/flow-control.html.7bdbc637.js"><link rel="prefetch" href="/assets/javadoc.html.2afc4df6.js"><link rel="prefetch" href="/assets/operator.html.e64288d7.js"><link rel="prefetch" href="/assets/java-basic-34.html.91c6cf38.js"><link rel="prefetch" href="/assets/java-basic.html.08a091ff.js"><link rel="prefetch" href="/assets/java-thread.html.05b97938.js"><link rel="prefetch" href="/assets/jvm.html.0ad26927.js"><link rel="prefetch" href="/assets/beijing.html.4b51f55c.js"><link rel="prefetch" href="/assets/chengdu.html.0d23c3b6.js"><link rel="prefetch" href="/assets/guangzhou.html.2a4b3d7f.js"><link rel="prefetch" href="/assets/hangzhou.html.5199039c.js"><link rel="prefetch" href="/assets/nanjing.html.546840f5.js"><link rel="prefetch" href="/assets/qingdao.html.246a16d0.js"><link rel="prefetch" href="/assets/shenzhen.html.ee9f1ec0.js"><link rel="prefetch" href="/assets/suzhou.html.90746b64.js"><link rel="prefetch" href="/assets/xian.html.e1b1cb14.js"><link rel="prefetch" href="/assets/zhengzhou.html.d44c5e4c.js"><link rel="prefetch" href="/assets/48-keywords.html.3f5c2be6.js"><link rel="prefetch" href="/assets/Overriding.html.025809db.js"><link rel="prefetch" href="/assets/annotation.html.97d2b965.js"><link rel="prefetch" href="/assets/box.html.3b948211.js"><link rel="prefetch" href="/assets/class-object.html.5826eeb9.js"><link rel="prefetch" href="/assets/comparable-omparator.html.7947fae2.js"><link rel="prefetch" href="/assets/deep-copy.html.484ecd9c.js"><link rel="prefetch" href="/assets/enum.html.a0be5fc2.js"><link rel="prefetch" href="/assets/equals-hashcode.html.5b7d6cfd.js"><link rel="prefetch" href="/assets/fanshe.html.10fa5560.js"><link rel="prefetch" href="/assets/generic.html.0612644c.js"><link rel="prefetch" href="/assets/hashcode.html.6524e67a.js"><link rel="prefetch" href="/assets/immutable.html.3aab08b3.js"><link rel="prefetch" href="/assets/instanceof-jvm.html.3da701f6.js"><link rel="prefetch" href="/assets/int-cache.html.b17f8298.js"><link rel="prefetch" href="/assets/java-naming.html.806e939e.js"><link rel="prefetch" href="/assets/java-unicode.html.a7433d6b.js"><link rel="prefetch" href="/assets/jdk-while-for-wuxian-xunhuan.html.9ef45b3d.js"><link rel="prefetch" href="/assets/jdk9-char-byte-string.html.d33c3386.js"><link rel="prefetch" href="/assets/override-overload.html.8b1a8199.js"><link rel="prefetch" href="/assets/pass-by-value.html.0b75d5f0.js"><link rel="prefetch" href="/assets/true-generic.html.275c408e.js"><link rel="prefetch" href="/assets/varables.html.185b0803.js"><link rel="prefetch" href="/assets/arraylist.html.9dd2c1a8.js"><link rel="prefetch" href="/assets/fail-fast.html.605cc7eb.js"><link rel="prefetch" href="/assets/gailan.html.b62fe145.js"><link rel="prefetch" href="/assets/hashmap-interview.html.b3c70b85.js"><link rel="prefetch" href="/assets/hashmap.html.d09f6ec3.js"><link rel="prefetch" href="/assets/iterator-iterable.html.787d7caa.js"><link rel="prefetch" href="/assets/linkedlist.html.1ca05798.js"><link rel="prefetch" href="/assets/list-war-2.html.ed59c49e.js"><link rel="prefetch" href="/assets/arrays.html.47f157a6.js"><link rel="prefetch" href="/assets/collections.html.c10b0630.js"><link rel="prefetch" href="/assets/guava.html.17d4e0b8.js"><link rel="prefetch" href="/assets/hutool.html.879258da.js"><link rel="prefetch" href="/assets/os.html.14c339a8.js"><link rel="prefetch" href="/assets/wangluo.html.5fd246e5.js"><link rel="prefetch" href="/assets/bat-shuati.html.21e3d90f.js"><link rel="prefetch" href="/assets/history.html.ece8dd67.js"><link rel="prefetch" href="/assets/java.html.5913634c.js"><link rel="prefetch" href="/assets/jianli.html.d6380b5b.js"><link rel="prefetch" href="/assets/learn-jianyi.html.b2886ff5.js"><link rel="prefetch" href="/assets/nicearticle.html.7d7ad8b5.js"><link rel="prefetch" href="/assets/pdf.html.f2f7fd2a.js"><link rel="prefetch" href="/assets/progit.html.4f73b0c7.js"><link rel="prefetch" href="/assets/yuanyifeng-c-language.html.da6c4453.js"><link rel="prefetch" href="/assets/rumen.html.410de8a6.js"><link rel="prefetch" href="/assets/gailan.html.5f0f3260.js"><link rel="prefetch" href="/assets/npe.html.309c7521.js"><link rel="prefetch" href="/assets/shijian.html.cf7b1168.js"><link rel="prefetch" href="/assets/try-with-resouces.html.ce4a4857.js"><link rel="prefetch" href="/assets/git-qiyuan.html.e22af3e2.js"><link rel="prefetch" href="/assets/progit.html.ed7722b7.js"><link rel="prefetch" href="/assets/Chocolatey-Homebrew.html.0cf98292.js"><link rel="prefetch" href="/assets/DBeaver.html.8e984cee.js"><link rel="prefetch" href="/assets/chiner.html.235bafd3.js"><link rel="prefetch" href="/assets/choco.html.35237804.js"><link rel="prefetch" href="/assets/fastjson.html.68b1100d.js"><link rel="prefetch" href="/assets/forest.html.2a9a691a.js"><link rel="prefetch" href="/assets/gson.html.551a4df2.js"><link rel="prefetch" href="/assets/jackson.html.bc67b4b5.js"><link rel="prefetch" href="/assets/junit.html.d96206d8.js"><link rel="prefetch" href="/assets/knife4j.html.45e41870.js"><link rel="prefetch" href="/assets/log4j.html.29992fac.js"><link rel="prefetch" href="/assets/log4j2.html.72b8a86b.js"><link rel="prefetch" href="/assets/logback.html.e6c675dd.js"><link rel="prefetch" href="/assets/others.html.e0ec05d2.js"><link rel="prefetch" href="/assets/slf4j.html.dbd1bb73.js"><link rel="prefetch" href="/assets/tabby.html.fa8994a4.js"><link rel="prefetch" href="/assets/warp.html.1c13135d.js"><link rel="prefetch" href="/assets/4-debug-skill.html.555511c5.js"><link rel="prefetch" href="/assets/BIONIOAIO.html.ab38a1bd.js"><link rel="prefetch" href="/assets/shangtou.html.1967dff3.js"><link rel="prefetch" href="/assets/Lambda.html.5d7c5402.js"><link rel="prefetch" href="/assets/optional.html.cfe425ae.js"><link rel="prefetch" href="/assets/stream.html.9edc0a12.js"><link rel="prefetch" href="/assets/asm.html.c87432ea.js"><link rel="prefetch" href="/assets/bytecode.html.db25d9c6.js"><link rel="prefetch" href="/assets/class-file-jiegou.html.76e328e6.js"><link rel="prefetch" href="/assets/class-load.html.75462d87.js"><link rel="prefetch" href="/assets/compile-jdk.html.50fe8400.js"><link rel="prefetch" href="/assets/cpu-percent-100.html.aadfe8d5.js"><link rel="prefetch" href="/assets/gc.html.fd16f184.js"><link rel="prefetch" href="/assets/how-jvm-run-zijiema-zhiling.html.b27380f2.js"><link rel="prefetch" href="/assets/how-run-java-code.html.cdcdceaf.js"><link rel="prefetch" href="/assets/hsdb.html.b9d89c49.js"><link rel="prefetch" href="/assets/jit.html.318fab0d.js"><link rel="prefetch" href="/assets/meituan-9-gc.html.a83f9a86.js"><link rel="prefetch" href="/assets/neicun-jiegou.html.f8eaccfb.js"><link rel="prefetch" href="/assets/oom.html.0505950b.js"><link rel="prefetch" href="/assets/problem-tools.html.a9103b8b.js"><link rel="prefetch" href="/assets/tujie-gc.html.f0647732.js"><link rel="prefetch" href="/assets/what-happen-when-javac.html.e7caad8a.js"><link rel="prefetch" href="/assets/what-is-jvm.html.eb700e27.js"><link rel="prefetch" href="/assets/whereis-the-object.html.f6dae178.js"><link rel="prefetch" href="/assets/zijiema-zhiling.html.dd7f534b.js"><link rel="prefetch" href="/assets/zongjie.html.fde614c7.js"><link rel="prefetch" href="/assets/auto-generator.html.8c3083bf.js"><link rel="prefetch" href="/assets/index.html.c4bbc172.js"><link rel="prefetch" href="/assets/yuneban-wangyiyunyinyue.html.6bdd732d.js"><link rel="prefetch" href="/assets/waibao-1geyue.html.d6b82d0d.js"><link rel="prefetch" href="/assets/yanjiusuo-20wan.html.73bb035e.js"><link rel="prefetch" href="/assets/maven.html.6ba773d7.js"><link rel="prefetch" href="/assets/redis12question.html.da423a40.js"><link rel="prefetch" href="/assets/shanganaliyun.html.f405748b.js"><link rel="prefetch" href="/assets/api-wangguan.html.8ac5c98c.js"><link rel="prefetch" href="/assets/rumen.html.91cda1ac.js"><link rel="prefetch" href="/assets/100-budiushi.html.99d5a0d4.js"><link rel="prefetch" href="/assets/rabbitmq-rumen.html.49feef8e.js"><link rel="prefetch" href="/assets/deletedb-binlog-weiguanjishu.html.92e7e140.js"><link rel="prefetch" href="/assets/redis-shuju-yizhixing.html.268d4c2e.js"><link rel="prefetch" href="/assets/40-interview.html.1fea0308.js"><link rel="prefetch" href="/assets/nginx.html.c4a54a10.js"><link rel="prefetch" href="/assets/BOKEYUANruhegaoxiaodixuexijishu.html.5b718b29.js"><link rel="prefetch" href="/assets/ZHIHUjavaxuexidaoshemechengduokeyizhaodiyifengongzuo.html.2d6ea1ec.js"><link rel="prefetch" href="/assets/bokeyuan-jianxijavazhongdifangwenquanxiankongzhi.html.7bcefa53.js"><link rel="prefetch" href="/assets/bokeyuan-ruhegaoxiaodixuexijishu.html.e9cc10bf.js"><link rel="prefetch" href="/assets/haibukuaiyongmybatisplusshoubashoujiaoni.html.0e5a46a3.js"><link rel="prefetch" href="/assets/javaxuexidaoshemechengduokeyizhaodiyifengongzuo.html.90631d0b.js"><link rel="prefetch" href="/assets/jiagoushizenyanghuizhijitongjiagoulantu.html.1ed5611e.js"><link rel="prefetch" href="/assets/jielehenduosihuodiganchu.html.faeee5bb.js"><link rel="prefetch" href="/assets/jishuzongjianbeikaichuliao.html.7416f959.js"><link rel="prefetch" href="/assets/weixin-zuixinbujiabandigongsimingdan.html.62d0afa3.js"><link rel="prefetch" href="/assets/abstract.html.1186a848.js"><link rel="prefetch" href="/assets/code-init.html.cc4c8a4d.js"><link rel="prefetch" href="/assets/construct.html.44432b48.js"><link rel="prefetch" href="/assets/final.html.c75c3034.js"><link rel="prefetch" href="/assets/inner-class.html.dfa64254.js"><link rel="prefetch" href="/assets/instanceof.html.b9a9d131.js"><link rel="prefetch" href="/assets/interface.html.75e1df46.js"><link rel="prefetch" href="/assets/method.html.03418cd4.js"><link rel="prefetch" href="/assets/object-class.html.027c87a4.js"><link rel="prefetch" href="/assets/static.html.a1b3ea54.js"><link rel="prefetch" href="/assets/this-super.html.87fd51b2.js"><link rel="prefetch" href="/assets/var.html.e5a46b4d.js"><link rel="prefetch" href="/assets/redis-springboot.html.9492858c.js"><link rel="prefetch" href="/assets/rumen.html.e67ba968.js"><link rel="prefetch" href="/assets/xuebeng-chuantou-jichuan.html.3308258f.js"><link rel="prefetch" href="/assets/hello-world.html.6d11bcad.js"><link rel="prefetch" href="/assets/what-is-java.html.33e36c54.js"><link rel="prefetch" href="/assets/image-yasuo.html.d46c9957.js"><link rel="prefetch" href="/assets/log4j2.html.683f14d7.js"><link rel="prefetch" href="/assets/computer-base.html.8586980c.js"><link rel="prefetch" href="/assets/Filter-Interceptor-Listener.html.e944f219.js"><link rel="prefetch" href="/assets/aop-log.html.e6c7993e.js"><link rel="prefetch" href="/assets/cors.html.96316dbf.js"><link rel="prefetch" href="/assets/initializr.html.4ac60ec6.js"><link rel="prefetch" href="/assets/ioc.html.726f2fb5.js"><link rel="prefetch" href="/assets/jpa.html.ca39a02f.js"><link rel="prefetch" href="/assets/jwt.html.50fe641d.js"><link rel="prefetch" href="/assets/logback.html.9d695f98.js"><link rel="prefetch" href="/assets/mysql-druid.html.aae312e0.js"><link rel="prefetch" href="/assets/oss.html.88d1224b.js"><link rel="prefetch" href="/assets/springtask.html.680998e8.js"><link rel="prefetch" href="/assets/swagger.html.60e0022b.js"><link rel="prefetch" href="/assets/thymeleaf.html.1fd2b010.js"><link rel="prefetch" href="/assets/tomcat.html.e42785c1.js"><link rel="prefetch" href="/assets/transaction.html.e8d55302.js"><link rel="prefetch" href="/assets/constant-pool.html.659d12c2.js"><link rel="prefetch" href="/assets/equals.html.adce6ec2.js"><link rel="prefetch" href="/assets/immutable.html.ebc3eed9.js"><link rel="prefetch" href="/assets/intern.html.83c72993.js"><link rel="prefetch" href="/assets/join.html.4d4f6cbb.js"><link rel="prefetch" href="/assets/split.html.225cecad.js"><link rel="prefetch" href="/assets/tobebetterjavaer-beian.html.acf34927.js"><link rel="prefetch" href="/assets/tobebetterjavaer-wangzhan-shangxian.html.5e7c348a.js"><link rel="prefetch" href="/assets/tupian-zhuanlian.html.cc21eebb.js"><link rel="prefetch" href="/assets/BlockingQueue.html.8e35e739.js"><link rel="prefetch" href="/assets/ConcurrentHashMap.html.a19e67cc.js"><link rel="prefetch" href="/assets/ConcurrentLinkedQueue.html.8b52c283.js"><link rel="prefetch" href="/assets/CopyOnWriteArrayList.html.cedae443.js"><link rel="prefetch" href="/assets/CountDownLatch.html.597b764d.js"><link rel="prefetch" href="/assets/LockSupport.html.512cd59b.js"><link rel="prefetch" href="/assets/ReentrantReadWriteLock.html.716cccf0.js"><link rel="prefetch" href="/assets/ScheduledThreadPoolExecutor.html.c3eb011f.js"><link rel="prefetch" href="/assets/ThreadLocal.html.c88367bf.js"><link rel="prefetch" href="/assets/ali-executors.html.f069581a.js"><link rel="prefetch" href="/assets/aqs.html.60c41861.js"><link rel="prefetch" href="/assets/atomic.html.760f5da3.js"><link rel="prefetch" href="/assets/cas.html.f3a36ace.js"><link rel="prefetch" href="/assets/condition.html.9011dc45.js"><link rel="prefetch" href="/assets/fork-join.html.26eacfb7.js"><link rel="prefetch" href="/assets/jmm.html.de1c0436.js"><link rel="prefetch" href="/assets/lock.html.9418ba4f.js"><link rel="prefetch" href="/assets/map.html.8344b61a.js"><link rel="prefetch" href="/assets/pool.html.64b73593.js"><link rel="prefetch" href="/assets/reentrantLock.html.10ae995d.js"><link rel="prefetch" href="/assets/shengchanzhe-xiaofeizhe.html.5ee201ac.js"><link rel="prefetch" href="/assets/synchronized.html.dfe16640.js"><link rel="prefetch" href="/assets/thread-bring-some-problem.html.063298d0.js"><link rel="prefetch" href="/assets/thread-group-and-thread-priority.html.28722e73.js"><link rel="prefetch" href="/assets/thread-state-and-method.html.e1c19d97.js"><link rel="prefetch" href="/assets/wangzhe-thread.html.c452821f.js"><link rel="prefetch" href="/assets/why-need-thread.html.81f1789f.js"><link rel="prefetch" href="/assets/electron-information-engineering.html.533214e9.js"><link rel="prefetch" href="/assets/read-csapp.html.6565710f.js"><link rel="prefetch" href="/assets/aliyun-shuaiguo-gongchengshi.html.d0413877.js"><link rel="prefetch" href="/assets/chadiansanhuo.html.2ad2b61a.js"><link rel="prefetch" href="/assets/chengxuyuannv-chonghui-java.html.7e69b528.js"><link rel="prefetch" href="/assets/daxue-nuli-jisuanji.html.b6dd444a.js"><link rel="prefetch" href="/assets/fumutuanju.html.5253a657.js"><link rel="prefetch" href="/assets/algorithm.html.1a5c5b5d.js"><link rel="prefetch" href="/assets/c.html.43eef5e4.js"><link rel="prefetch" href="/assets/ccc.html.eb6e3187.js"><link rel="prefetch" href="/assets/go.html.dbe14a0d.js"><link rel="prefetch" href="/assets/lanqiaobei.html.8b276298.js"><link rel="prefetch" href="/assets/os.html.8dd8cc84.js"><link rel="prefetch" href="/assets/python.html.6418b876.js"><link rel="prefetch" href="/assets/qianduan.html.40631b0b.js"><link rel="prefetch" href="/assets/index.html.391d63d4.js"><link rel="prefetch" href="/assets/java-mianshi-zhinan.html.d28f9785.js"><link rel="prefetch" href="/assets/index.html.7141d4e9.js"><link rel="prefetch" href="/assets/jibenjieshao.html.5231f64b.js"><link rel="prefetch" href="/assets/mysql.html.ad7a53f1.js"><link rel="prefetch" href="/assets/collection.html.932704cd.js"><link rel="prefetch" href="/assets/javase.html.796dad93.js"><link rel="prefetch" href="/assets/javathread.html.79db820f.js"><link rel="prefetch" href="/assets/jvm.html.57f26f82.js"><link rel="prefetch" href="/assets/nixi.html.7806ef71.js"><link rel="prefetch" href="/assets/redis.html.ae8349a3.js"><link rel="prefetch" href="/assets/spring.html.c2c775a0.js"><link rel="prefetch" href="/assets/jvm.html.3d726613.js"><link rel="prefetch" href="/assets/thread.html.aae60aaa.js"><link rel="prefetch" href="/assets/yitiaolong.html.6689847e.js"><link rel="prefetch" href="/assets/404.html.bdfd9260.js"><link rel="prefetch" href="/assets/404.48cd9f1c.js"><link rel="prefetch" href="/assets/Layout.2a043630.js"><link rel="prefetch" href="/assets/Slide.482811fd.js"><link rel="prefetch" href="/assets/giscus.es.3a0b2457.js"><link rel="prefetch" href="/assets/highlight.esm.d982e650.js"><link rel="prefetch" href="/assets/markdown.esm.832a189d.js"><link rel="prefetch" href="/assets/math.esm.a3f84b6f.js"><link rel="prefetch" href="/assets/notes.esm.3c361cb7.js"><link rel="prefetch" href="/assets/reveal.esm.b96f05d8.js"><link rel="prefetch" href="/assets/search.esm.80da4a02.js"><link rel="prefetch" href="/assets/zoom.esm.8514a202.js"><link rel="prefetch" href="/assets/photoswipe.esm.92018b73.js">
  </head>
  <body>
    <div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content" class="skip-link sr-only">Skip to content</a><!--]--><div class="theme-container has-toc"><!--[--><!--[--><header class="navbar"><div class="navbar-left"><button class="toggle-sidebar-button" title="Toggle Sidebar"><span class="icon"></span></button><!----><a href="/" class="brand"><img class="logo" src="http://cdn.tobebetterjavaer.com/tobebetterjavaer/images/logo-02.png" alt="Java 程序员进阶之路"><!----><span class="site-name hide-in-pad">Java 程序员进阶之路</span></a><!----></div><div class="navbar-center"><!----><nav class="nav-links"><div class="nav-item hide-in-mobile"><a href="/home.html" class="nav-link" aria-label="进阶之路"><span class="icon iconfont icon-lujing" style=""></span>进阶之路<!----></a></div><div class="nav-item hide-in-mobile"><a href="/zhishixingqiu/java-mianshi-zhinan.html" class="nav-link" aria-label="星球专栏"><span class="icon iconfont icon-Artboard" style=""></span>星球专栏<!----></a></div><div class="nav-item hide-in-mobile"><a href="/xuexiluxian/" class="nav-link" aria-label="学习路线"><span class="icon iconfont icon-luxian" style=""></span>学习路线<!----></a></div><div class="nav-item hide-in-mobile"><a href="https://space.bilibili.com/513340480" rel="noopener noreferrer" target="_blank" aria-label="B站视频" class="nav-link"><span class="icon iconfont icon-bzhan" style=""></span>B站视频<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a></div><div class="nav-item hide-in-mobile"><div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="珍藏资源"><span class="title"><span class="icon iconfont icon-youzhi" style=""></span>珍藏资源</span><span class="arrow"></span><ul class="nav-dropdown"><li class="dropdown-item"><a href="/download/java.html" class="nav-link" aria-label="Java电子书下载"><span class="icon iconfont icon-java" style=""></span>Java电子书下载<!----></a></li><li class="dropdown-item"><a href="/download/pdf.html" class="nav-link" aria-label="PDF干货笔记下载"><span class="icon iconfont icon-pdf" style=""></span>PDF干货笔记下载<!----></a></li><li class="dropdown-item"><a href="/download/learn-jianyi.html" class="nav-link" aria-label="学习建议"><span class="icon iconfont icon-xuexijianyi" style=""></span>学习建议<!----></a></li><li class="dropdown-item"><a href="/sidebar/sanfene/nixi.html" class="nav-link" aria-label="面渣逆袭"><span class="icon iconfont icon-zhunbei" style=""></span>面渣逆袭<!----></a></li><li class="dropdown-item"><a href="/download/nicearticle.html" class="nav-link" aria-label="优质文章"><span class="icon iconfont icon-youzhi" style=""></span>优质文章<!----></a></li><li class="dropdown-item"><a href="/download/history.html" class="nav-link" aria-label="网络日志"><span class="icon iconfont icon-rizhi" style=""></span>网络日志<!----></a></li><li class="dropdown-item"><a href="https://docsify.tobebetterjavaer.com/" rel="noopener noreferrer" target="_blank" aria-label="回到过去" class="nav-link"><span class="icon iconfont icon-fanhuijiuban" style=""></span>回到过去<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a></li></ul></button></div></div></nav><!----></div><div class="navbar-right"><!----><div class="nav-item"><!----></div><div class="nav-item"><a class="repo-link" href="https://github.com/itwanger/toBeBetterJavaer" target="_blank" rel="noopener noreferrer"><svg xmlns="http://www.w3.org/2000/svg" class="icon github-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="github icon" style="width:1.25rem;height:1.25rem;vertical-align:middle;"><path d="M511.957 21.333C241.024 21.333 21.333 240.981 21.333 512c0 216.832 140.544 400.725 335.574 465.664 24.49 4.395 32.256-10.07 32.256-23.083 0-11.69.256-44.245 0-85.205-136.448 29.61-164.736-64.64-164.736-64.64-22.315-56.704-54.4-71.765-54.4-71.765-44.587-30.464 3.285-29.824 3.285-29.824 49.195 3.413 75.179 50.517 75.179 50.517 43.776 75.008 114.816 53.333 142.762 40.79 4.523-31.66 17.152-53.377 31.19-65.537-108.971-12.458-223.488-54.485-223.488-242.602 0-53.547 19.114-97.323 50.517-131.67-5.035-12.33-21.93-62.293 4.779-129.834 0 0 41.258-13.184 134.912 50.346a469.803 469.803 0 0 1 122.88-16.554c41.642.213 83.626 5.632 122.88 16.554 93.653-63.488 134.784-50.346 134.784-50.346 26.752 67.541 9.898 117.504 4.864 129.834 31.402 34.347 50.474 78.123 50.474 131.67 0 188.586-114.73 230.016-224.042 242.09 17.578 15.232 33.578 44.672 33.578 90.454v135.85c0 13.142 7.936 27.606 32.854 22.87C862.25 912.597 1002.667 728.747 1002.667 512c0-271.019-219.648-490.667-490.71-490.667z"></path></svg></a></div><div class="nav-item hide-in-mobile"><button id="appearance-switch"><svg xmlns="http://www.w3.org/2000/svg" class="icon auto-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="auto icon" style="display:block;"><path d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="dark icon" style="display:none;"><path d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="light icon" style="display:none;"><path d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z"></path></svg></button></div><div id="docsearch-container"></div><!----><button class="toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false" aria-controls="nav-screen"><span class="button-container"><span class="button-top"></span><span class="button-middle"></span><span class="button-bottom"></span></span></button></div></header><!----><!--]--><!----><div class="toggle-sidebar-wrapper"><span class="arrow left"></span></div><aside class="sidebar"><!--[--><!----><!--]--><ul class="sidebar-links"><li><!--[--><a href="/home.html" class="nav-link sidebar-link sidebar-page" aria-label="一、前言"><!---->一、前言<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable active"><!----><span class="title">二、Java核心</span><span class="arrow down"></span></button><ul class="sidebar-links"><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.1 Java概述</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.2 Java基础语法</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.3 面向对象编程</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.4 字符串&amp;数组</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.5 集合框架(容器)</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.6 IO</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.7 异常处理</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.8 常用工具类</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.9 Java新特性</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.10 Java重要知识点</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable active"><!----><span class="title">2.11 并发编程</span><span class="arrow down"></span></button><ul class="sidebar-links"><li><!--[--><a href="/thread/wangzhe-thread.html" class="nav-link sidebar-link sidebar-page" aria-label="创建Java线程的3种方式"><!---->创建Java线程的3种方式<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/thread-state-and-method.html" class="nav-link sidebar-link sidebar-page" aria-label="线程的6种状态及切换"><!---->线程的6种状态及切换<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/thread-group-and-thread-priority.html" class="nav-link sidebar-link sidebar-page" aria-label="线程组和线程优先级"><!---->线程组和线程优先级<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/why-need-thread.html" class="nav-link sidebar-link sidebar-page" aria-label="进程与线程的区别"><!---->进程与线程的区别<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/thread-bring-some-problem.html" class="nav-link sidebar-link sidebar-page" aria-label="并发编程带来了哪些问题"><!---->并发编程带来了哪些问题<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/jmm.html" class="nav-link sidebar-link sidebar-page" aria-label="Java内存模型"><!---->Java内存模型<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a aria-current="page" href="/thread/volatile.html" class="router-link-active router-link-exact-active nav-link active sidebar-link sidebar-page active" aria-label="volatile"><!---->volatile<!----></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#几个基本概念" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="几个基本概念"><!---->几个基本概念<!----></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#内存可见性" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="内存可见性"><!---->内存可见性<!----></a><ul class="sidebar-sub-headers"></ul></li><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#重排序" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="重排序"><!---->重排序<!----></a><ul class="sidebar-sub-headers"></ul></li><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#happens-before规则" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="happens-before规则"><!---->happens-before规则<!----></a><ul class="sidebar-sub-headers"></ul></li></ul></li><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#volatile的内存语义" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="volatile的内存语义"><!---->volatile的内存语义<!----></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#内存可见性-1" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="内存可见性"><!---->内存可见性<!----></a><ul class="sidebar-sub-headers"></ul></li><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#禁止重排序" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="禁止重排序"><!---->禁止重排序<!----></a><ul class="sidebar-sub-headers"></ul></li></ul></li><li class="sidebar-sub-header"><a aria-current="page" href="/thread/volatile.html#volatile的用途" class="router-link-active router-link-exact-active nav-link sidebar-link heading" aria-label="volatile的用途"><!---->volatile的用途<!----></a><ul class="sidebar-sub-headers"></ul></li></ul><!--]--></li><li><!--[--><a href="/thread/synchronized.html" class="nav-link sidebar-link sidebar-page" aria-label="synchronized"><!---->synchronized<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/cas.html" class="nav-link sidebar-link sidebar-page" aria-label="CAS的原理"><!---->CAS的原理<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/aqs.html" class="nav-link sidebar-link sidebar-page" aria-label="AQS详解"><!---->AQS详解<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/lock.html" class="nav-link sidebar-link sidebar-page" aria-label="锁"><!----><!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/reentrantLock.html" class="nav-link sidebar-link sidebar-page" aria-label="重入锁ReentrantLock"><!---->重入锁ReentrantLock<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/ReentrantReadWriteLock.html" class="nav-link sidebar-link sidebar-page" aria-label="读写锁ReentrantReadWriteLock"><!---->读写锁ReentrantReadWriteLock<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/condition.html" class="nav-link sidebar-link sidebar-page" aria-label="线程协作类Condition"><!---->线程协作类Condition<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/LockSupport.html" class="nav-link sidebar-link sidebar-page" aria-label="线程阻塞唤醒类LockSupport"><!---->线程阻塞唤醒类LockSupport<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/map.html" class="nav-link sidebar-link sidebar-page" aria-label="并发集合容器"><!---->并发集合容器<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/ConcurrentHashMap.html" class="nav-link sidebar-link sidebar-page" aria-label="ConcurrentHashMap"><!---->ConcurrentHashMap<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/ConcurrentLinkedQueue.html" class="nav-link sidebar-link sidebar-page" aria-label="ConcurrentLinkedQueue"><!---->ConcurrentLinkedQueue<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/CopyOnWriteArrayList.html" class="nav-link sidebar-link sidebar-page" aria-label="CopyOnWriteArrayList"><!---->CopyOnWriteArrayList<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/ThreadLocal.html" class="nav-link sidebar-link sidebar-page" aria-label="ThreadLocal"><!---->ThreadLocal<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/BlockingQueue.html" class="nav-link sidebar-link sidebar-page" aria-label="BlockingQueue"><!---->BlockingQueue<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/pool.html" class="nav-link sidebar-link sidebar-page" aria-label="线程池"><!---->线程池<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/ScheduledThreadPoolExecutor.html" class="nav-link sidebar-link sidebar-page" aria-label="计划任务"><!---->计划任务<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/atomic.html" class="nav-link sidebar-link sidebar-page" aria-label="原子操作类"><!---->原子操作类<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/CountDownLatch.html" class="nav-link sidebar-link sidebar-page" aria-label="通信工具类CountDownLatch"><!---->通信工具类CountDownLatch<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/fork-join.html" class="nav-link sidebar-link sidebar-page" aria-label="Fork/Join框架"><!---->Fork/Join框架<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li><li><!--[--><a href="/thread/shengchanzhe-xiaofeizhe.html" class="nav-link sidebar-link sidebar-page" aria-label="生产者-消费者模式"><!---->生产者-消费者模式<!----></a><ul class="sidebar-sub-headers"></ul><!--]--></li></ul></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">2.12 JVM</span><span class="arrow right"></span></button><!----></section><!--]--></li></ul></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">三、Java企业级开发</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">四、数据库</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">五、计算机基础</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">六、求职面试</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">七、学习资源</span><span class="arrow right"></span></button><!----></section><!--]--></li><li><!--[--><section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">八、联系作者</span><span class="arrow right"></span></button><!----></section><!--]--></li></ul><!--[--><!----><!--]--></aside><!--[--><main class="page" id="main-content"><!--[--><!----><nav class="breadcrumb disable"></nav><div class="page-title"><h1><!---->Java并发编程volatile关键字解析</h1><div class="page-info"><span class="author-info" aria-label="作者🖊" data-balloon-pos="down" isoriginal="false" pageview="false"><svg xmlns="http://www.w3.org/2000/svg" class="icon author-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="author icon"><path d="M649.6 633.6c86.4-48 147.2-144 147.2-249.6 0-160-128-288-288-288s-288 128-288 288c0 108.8 57.6 201.6 147.2 249.6-121.6 48-214.4 153.6-240 288-3.2 9.6 0 19.2 6.4 25.6 3.2 9.6 12.8 12.8 22.4 12.8h704c9.6 0 19.2-3.2 25.6-12.8 6.4-6.4 9.6-16 6.4-25.6-25.6-134.4-121.6-240-243.2-288z"></path></svg><span><a class="author-item" href="https://tobebetterjavaer.com" target="_blank" rel="noopener noreferrer">沉默王二</a></span><span property="author" content="沉默王二"></span></span><!----><span class="date-info" aria-label="写作日期📅" data-balloon-pos="down" isoriginal="false" pageview="false"><svg xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="calendar icon"><path d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z"></path></svg><span>2022年3月23日</span><meta property="datePublished" content="2022-03-23T12:08:58.000Z"></span><span class="category-info" aria-label="分类🌈" data-balloon-pos="down" isoriginal="false" pageview="false"><svg xmlns="http://www.w3.org/2000/svg" class="icon category-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="category icon"><path d="M148.41 106.992h282.176c22.263 0 40.31 18.048 40.31 40.31V429.48c0 22.263-18.047 40.31-40.31 40.31H148.41c-22.263 0-40.311-18.047-40.311-40.31V147.302c0-22.263 18.048-40.31 40.311-40.31zM147.556 553.478H429.73c22.263 0 40.311 18.048 40.311 40.31v282.176c0 22.263-18.048 40.312-40.31 40.312H147.555c-22.263 0-40.311-18.049-40.311-40.312V593.79c0-22.263 18.048-40.311 40.31-40.311zM593.927 106.992h282.176c22.263 0 40.31 18.048 40.31 40.31V429.48c0 22.263-18.047 40.31-40.31 40.31H593.927c-22.263 0-40.311-18.047-40.311-40.31V147.302c0-22.263 18.048-40.31 40.31-40.31zM730.22 920.502H623.926c-40.925 0-74.22-33.388-74.22-74.425V623.992c0-41.038 33.387-74.424 74.425-74.424h222.085c41.038 0 74.424 33.226 74.424 74.067v114.233c0 10.244-8.304 18.548-18.547 18.548s-18.548-8.304-18.548-18.548V623.635c0-20.388-16.746-36.974-37.33-36.974H624.13c-20.585 0-37.331 16.747-37.331 37.33v222.086c0 20.585 16.654 37.331 37.126 37.331H730.22c10.243 0 18.547 8.304 18.547 18.547 0 10.244-8.304 18.547-18.547 18.547z"></path></svg><ul class="categories-wrapper"><li class="category category0" role>Java核心</li><li class="category category6" role>并发编程</li><meta property="articleSection" content="Java核心,并发编程"></ul></span><span aria-label="标签🏷" data-balloon-pos="down" isoriginal="false" pageview="false"><svg xmlns="http://www.w3.org/2000/svg" class="icon tag-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="tag icon"><path d="M939.902 458.563L910.17 144.567c-1.507-16.272-14.465-29.13-30.737-30.737L565.438 84.098h-.402c-3.215 0-5.726 1.005-7.634 2.913l-470.39 470.39a10.004 10.004 0 000 14.164l365.423 365.424c1.909 1.908 4.42 2.913 7.132 2.913s5.223-1.005 7.132-2.913l470.39-470.39c2.01-2.11 3.014-5.023 2.813-8.036zm-240.067-72.121c-35.458 0-64.286-28.828-64.286-64.286s28.828-64.285 64.286-64.285 64.286 28.828 64.286 64.285-28.829 64.286-64.286 64.286z"></path></svg><ul class="tags-wrapper"><li class="tag tag4" role>Java</li></ul><meta property="keywords" content="Java"></span><span class="reading-time-info" aria-label="阅读时间⌛" data-balloon-pos="down" isoriginal="false" pageview="false"><svg xmlns="http://www.w3.org/2000/svg" class="icon timer-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="timer icon"><path d="M799.387 122.15c4.402-2.978 7.38-7.897 7.38-13.463v-1.165c0-8.933-7.38-16.312-16.312-16.312H256.33c-8.933 0-16.311 7.38-16.311 16.312v1.165c0 5.825 2.977 10.874 7.637 13.592 4.143 194.44 97.22 354.963 220.201 392.763-122.204 37.542-214.893 196.511-220.2 389.397-4.661 5.049-7.638 11.651-7.638 19.03v5.825h566.49v-5.825c0-7.379-2.849-13.981-7.509-18.9-5.049-193.016-97.867-351.985-220.2-389.527 123.24-37.67 216.446-198.453 220.588-392.892zM531.16 450.445v352.632c117.674 1.553 211.787 40.778 211.787 88.676H304.097c0-48.286 95.149-87.382 213.728-88.676V450.445c-93.077-3.107-167.901-81.297-167.901-177.093 0-8.803 6.99-15.793 15.793-15.793 8.803 0 15.794 6.99 15.794 15.793 0 80.261 63.69 145.635 142.01 145.635s142.011-65.374 142.011-145.635c0-8.803 6.99-15.793 15.794-15.793s15.793 6.99 15.793 15.793c0 95.019-73.789 172.82-165.96 177.093z"></path></svg><span>大约 8 分钟</span><meta property="timeRequired" content="PT8M"></span></div><hr></div><div class="toc-place-holder"><aside id="toc"><div class="toc-header">此页内容</div><div class="toc-wrapper"><ul class="toc-list"><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#几个基本概念" class="router-link-active router-link-exact-active toc-link level2">几个基本概念</a></li><ul class="toc-list"><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#内存可见性" class="router-link-active router-link-exact-active toc-link level3">内存可见性</a></li><!----><!--]--><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#重排序" class="router-link-active router-link-exact-active toc-link level3">重排序</a></li><!----><!--]--><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#happens-before规则" class="router-link-active router-link-exact-active toc-link level3">happens-before规则</a></li><!----><!--]--></ul><!--]--><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#volatile的内存语义" class="router-link-active router-link-exact-active toc-link level2">volatile的内存语义</a></li><ul class="toc-list"><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#内存可见性-1" class="router-link-active router-link-exact-active toc-link level3">内存可见性</a></li><!----><!--]--><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#禁止重排序" class="router-link-active router-link-exact-active toc-link level3">禁止重排序</a></li><!----><!--]--></ul><!--]--><!--[--><li class="toc-item"><a aria-current="page" href="/thread/volatile.html#volatile的用途" class="router-link-active router-link-exact-active toc-link level2">volatile的用途</a></li><!----><!--]--></ul></div></aside></div><!----><div class="theme-hope-content"><h1 id="java并发编程volatile关键字解析" tabindex="-1"><a class="header-anchor" href="#java并发编程volatile关键字解析" aria-hidden="true">#</a> Java并发编程volatile关键字解析</h1><h2 id="几个基本概念" tabindex="-1"><a class="header-anchor" href="#几个基本概念" aria-hidden="true">#</a> 几个基本概念</h2><p>在介绍volatile之前,我们先回顾及介绍几个基本的概念。</p><h3 id="内存可见性" tabindex="-1"><a class="header-anchor" href="#内存可见性" aria-hidden="true">#</a> 内存可见性</h3><p>在Java内存模型那一章我们介绍了JMM有一个主内存,每个线程有自己私有的工作内存,工作内存中保存了一些变量在主内存的拷贝。</p><p><strong>内存可见性,指的是线程之间的可见性,当一个线程修改了共享变量时,另一个线程可以读取到这个修改后的值</strong></p><h3 id="重排序" tabindex="-1"><a class="header-anchor" href="#重排序" aria-hidden="true">#</a> 重排序</h3><p>为优化程序性能,对原有的指令执行顺序进行优化重新排序。重排序可能发生在多个阶段,比如编译重排序、CPU重排序等。</p><h3 id="happens-before规则" tabindex="-1"><a class="header-anchor" href="#happens-before规则" aria-hidden="true">#</a> happens-before规则</h3><p>是一个给程序员使用的规则,只要程序员在写代码的时候遵循happens-before规则,JVM就能保证指令在多线程之间的顺序性符合程序员的预期。</p><h2 id="volatile的内存语义" tabindex="-1"><a class="header-anchor" href="#volatile的内存语义" aria-hidden="true">#</a> volatile的内存语义</h2><p>在Java中,volatile关键字有特殊的内存语义。volatile主要有以下两个功能:</p><ul><li>保证变量的<strong>内存可见性</strong></li><li>禁止volatile变量与普通变量<strong>重排序</strong>(JSR133提出,Java 5 开始才有这个“增强的volatile内存语义”)</li></ul><h3 id="内存可见性-1" tabindex="-1"><a class="header-anchor" href="#内存可见性-1" aria-hidden="true">#</a> 内存可见性</h3><p>以一段示例代码开始:</p><div class="language-java ext-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">VolatileExample</span> <span class="token punctuation">{</span>
    <span class="token keyword">int</span> a <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">volatile</span> <span class="token keyword">boolean</span> flag <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">writer</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> <span class="token comment">// step 1</span>
        flag <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span> <span class="token comment">// step 2</span>
    <span class="token punctuation">}</span>
    
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">reader</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>flag<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment">// step 3</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// step 4</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在这段代码里,我们使用<code>volatile</code>关键字修饰了一个<code>boolean</code>类型的变量<code>flag</code></p><p>所谓内存可见性,指的是当一个线程对<code>volatile</code>修饰的变量进行<strong>写操作</strong>(比如step 2)时,JMM会立即把该线程对应的本地内存中的共享变量的值刷新到主内存;当一个线程对<code>volatile</code>修饰的变量进行<strong>读操作</strong>(比如step 3)时,JMM会把立即该线程对应的本地内存置为无效,从主内存中读取共享变量的值。</p><blockquote><p>在这一点上,volatile与锁具有相同的内存效果,volatile变量的写和锁的释放具有相同的内存语义,volatile变量的读和锁的获取具有相同的内存语义。</p></blockquote><p>假设在时间线上,线程A先执行方法<code>writer</code>方法,线程B后执行<code>reader</code>方法。那必然会有下图:</p><p><img src="http://cdn.tobebetterjavaer.com/tobebetterjavaer/images/thread/volatile-1f5e263e-dd3e-4fb9-a21f-67e160b3dbf2.jpg" alt="volatile内存示意图"></p><p>而如果<code>flag</code>变量<strong>没有</strong><code>volatile</code>修饰,在step 2,线程A的本地内存里面的变量就不会立即更新到主内存,那随后线程B也同样不会去主内存拿最新的值,仍然使用线程B本地内存缓存的变量的值<code>a = 0,flag = false</code></p><h3 id="禁止重排序" tabindex="-1"><a class="header-anchor" href="#禁止重排序" aria-hidden="true">#</a> 禁止重排序</h3><p>在JSR-133之前的旧的Java内存模型中,是允许volatile变量与普通变量重排序的。那上面的案例中,可能就会被重排序成下列时序来执行:</p><ol><li>线程A写volatile变量,step 2,设置flag为true;</li><li>线程B读同一个volatile,step 3,读取到flag为true;</li><li>线程B读普通变量,step 4,读取到 a = 0;</li><li>线程A修改普通变量,step 1,设置 a = 1;</li></ol><p>可见,如果volatile变量与普通变量发生了重排序,虽然volatile变量能保证内存可见性,也可能导致普通变量读取错误。</p><p>所以在旧的内存模型中,volatile的写-读就不能与锁的释放-获取具有相同的内存语义了。为了提供一种比锁更轻量级的<strong>线程间的通信机制</strong><strong>JSR-133</strong>专家组决定增强volatile的内存语义:严格限制编译器和处理器对volatile变量与普通变量的重排序。</p><p>编译器还好说,JVM是怎么还能限制处理器的重排序的呢?它是通过<strong>内存屏障</strong>来实现的。</p><p>什么是内存屏障?硬件层面,内存屏障分两种:读屏障(Load Barrier)和写屏障(Store Barrier)。内存屏障有两个作用:</p><ol><li>阻止屏障两侧的指令重排序;</li><li>强制把写缓冲区/高速缓存中的脏数据等写回主内存,或者让缓存中相应的数据失效。</li></ol><blockquote><p>注意这里的缓存主要指的是CPU缓存,如L1,L2等</p></blockquote><p>编译器在<strong>生成字节码时</strong>,会在指令序列中插入内存屏障来禁止特定类型的处理器重排序。编译器选择了一个<strong>比较保守的JMM内存屏障插入策略</strong>,这样可以保证在任何处理器平台,任何程序中都能得到正确的volatile内存语义。这个策略是:</p><ul><li>在每个volatile写操作前插入一个StoreStore屏障;</li><li>在每个volatile写操作后插入一个StoreLoad屏障;</li><li>在每个volatile读操作后插入一个LoadLoad屏障;</li><li>在每个volatile读操作后再插入一个LoadStore屏障。</li></ul><p>大概示意图是这个样子:</p><p><img src="http://cdn.tobebetterjavaer.com/tobebetterjavaer/images/thread/volatile-aaa0fa44-341f-401f-bfb7-03d0c03dc2b1.png" alt="内存屏障"></p><blockquote><p>再逐个解释一下这几个屏障。注:下述Load代表读操作,Store代表写操作</p><p><strong>LoadLoad屏障</strong>:对于这样的语句Load1; LoadLoad; Load2,在Load2及后续读取操作要读取的数据被访问前,保证Load1要读取的数据被读取完毕。<br><strong>StoreStore屏障</strong>:对于这样的语句Store1; StoreStore; Store2,在Store2及后续写入操作执行前,这个屏障会把Store1强制刷新到内存,保证Store1的写入操作对其它处理器可见。<br><strong>LoadStore屏障</strong>:对于这样的语句Load1; LoadStore; Store2,在Store2及后续写入操作被刷出前,保证Load1要读取的数据被读取完毕。<br><strong>StoreLoad屏障</strong>:对于这样的语句Store1; StoreLoad; Load2,在Load2及后续所有读取操作执行前,保证Store1的写入对所有处理器可见。它的开销是四种屏障中最大的(冲刷写缓冲器,清空无效化队列)。在大多数处理器的实现中,这个屏障是个万能屏障,兼具其它三种内存屏障的功能</p></blockquote><p>对于连续多个volatile变量读或者连续多个volatile变量写,编译器做了一定的优化来提高性能,比如:</p><blockquote><p>第一个volatile读;</p><p>LoadLoad屏障;</p><p>第二个volatile读;</p><p>LoadStore屏障</p></blockquote><p>再介绍一下volatile与普通变量的重排序规则:</p><ol><li><p>如果第一个操作是volatile读,那无论第二个操作是什么,都不能重排序;</p></li><li><p>如果第二个操作是volatile写,那无论第一个操作是什么,都不能重排序;</p></li><li><p>如果第一个操作是volatile写,第二个操作是volatile读,那不能重排序。</p></li></ol><p>举个例子,我们在案例中step 1,是普通变量的写,step 2是volatile变量的写,那符合第2个规则,这两个steps不能重排序。而step 3是volatile变量读,step 4是普通变量读,符合第1个规则,同样不能重排序。</p><p>但如果是下列情况:第一个操作是普通变量读,第二个操作是volatile变量读,那是可以重排序的:</p><div class="language-java ext-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">// 声明变量</span>
<span class="token keyword">int</span> a <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token comment">// 声明普通变量</span>
<span class="token keyword">volatile</span> <span class="token keyword">boolean</span> flag <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span> <span class="token comment">// 声明volatile变量</span>

<span class="token comment">// 以下两个变量的读操作是可以重排序的</span>
<span class="token keyword">int</span> i <span class="token operator">=</span> a<span class="token punctuation">;</span> <span class="token comment">// 普通变量读</span>
<span class="token keyword">boolean</span> j <span class="token operator">=</span> flag<span class="token punctuation">;</span> <span class="token comment">// volatile变量读</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="volatile的用途" tabindex="-1"><a class="header-anchor" href="#volatile的用途" aria-hidden="true">#</a> volatile的用途</h2><p>从volatile的内存语义上来看,volatile可以保证内存可见性且禁止重排序。</p><p>在保证内存可见性这一点上,volatile有着与锁相同的内存语义,所以可以作为一个“轻量级”的锁来使用。但由于volatile仅仅保证对单个volatile变量的读/写具有原子性,而锁可以保证整个<strong>临界区代码</strong>的执行具有原子性。所以<strong>在功能上,锁比volatile更强大;在性能上,volatile更有优势</strong></p><p>在禁止重排序这一点上,volatile也是非常有用的。比如我们熟悉的单例模式,其中有一种实现方式是“双重锁检查”,比如这样的代码:</p><div class="language-java ext-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">Singleton</span> <span class="token punctuation">{</span>

    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token class-name">Singleton</span> instance<span class="token punctuation">;</span> <span class="token comment">// 不使用volatile关键字</span>
    
    <span class="token comment">// 双重锁检验</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Singleton</span> <span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>instance <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment">// 第7行</span>
            <span class="token keyword">synchronized</span> <span class="token punctuation">(</span><span class="token class-name">Singleton</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>instance <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    instance <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Singleton</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 第10行</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> instance<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果这里的变量声明不使用volatile关键字,是可能会发生错误的。它可能会被重排序:</p><div class="language-java ext-java line-numbers-mode"><pre class="language-java"><code>instance <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Singleton</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 第10行</span>

<span class="token comment">// 可以分解为以下三个步骤</span>
<span class="token number">1</span> memory<span class="token operator">=</span><span class="token function">allocate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 分配内存 相当于c的malloc</span>
<span class="token number">2</span> <span class="token function">ctorInstanc</span><span class="token punctuation">(</span>memory<span class="token punctuation">)</span> <span class="token comment">//初始化对象</span>
<span class="token number">3</span> s<span class="token operator">=</span>memory <span class="token comment">//设置s指向刚分配的地址</span>

<span class="token comment">// 上述三个步骤可能会被重排序为 1-3-2,也就是:</span>
<span class="token number">1</span> memory<span class="token operator">=</span><span class="token function">allocate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 分配内存 相当于c的malloc</span>
<span class="token number">3</span> s<span class="token operator">=</span>memory <span class="token comment">//设置s指向刚分配的地址</span>
<span class="token number">2</span> <span class="token function">ctorInstanc</span><span class="token punctuation">(</span>memory<span class="token punctuation">)</span> <span class="token comment">//初始化对象</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>而一旦假设发生了这样的重排序,比如线程A在第10行执行了步骤1和步骤3,但是步骤2还没有执行完。这个时候另一个线程B执行到了第7行,它会判定instance不为空,然后直接返回了一个未初始化完成的instance!</p><p>所以JSR-133对volatile做了增强后,volatile的禁止重排序功能还是非常有用的。</p><hr><blockquote><p>编辑:沉默王二,内容大部分来源以下三个开源仓库:</p><ul><li><a href="http://concurrent.redspider.group/" target="_blank" rel="noopener noreferrer">深入浅出 Java 多线程<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li><li><a href="https://github.com/CL0610/Java-concurrency" target="_blank" rel="noopener noreferrer">并发编程知识总结<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li><li><a href="https://github.com/CoderLeixiaoshuai/java-eight-part" target="_blank" rel="noopener noreferrer">Java八股文<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li></ul></blockquote><img src="http://cdn.tobebetterjavaer.com/tobebetterjavaer/images/xingbiaogongzhonghao.png"></div><!----><footer class="page-meta"><div class="meta-item edit-link"><a href="https://github.com/itwanger/toBeBetterJavaer/edit/master/docs/thread/volatile.md" rel="noopener noreferrer" target="_blank" aria-label="编辑此页" class="nav-link label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon edit-icon" viewbox="0 0 1024 1024" fill="currentColor" aria-label="edit icon"><path d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"></path><path d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"></path></svg><!--]-->编辑此页<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a></div><div class="meta-item update-time"><span class="label">上次编辑于: </span><span class="info">2022/5/12 16:24:21</span></div><div class="meta-item contributors"><span class="label">贡献者: </span><!--[--><!--[--><span class="contributor" title="email: www.qing_gee@163.com">itwanger</span>,<!--]--><!--[--><span class="contributor" title="email: www.qing_gee@163.com">沉默王二</span><!--]--><!--]--></div></footer><nav class="page-nav"><a href="/thread/jmm.html" class="nav-link prev" aria-label="Java内存模型"><div class="hint"><span class="arrow left"></span>上一页</div><div class="link"><!---->Java内存模型</div></a><a href="/thread/synchronized.html" class="nav-link next" aria-label="synchronized"><div class="hint">下一页<span class="arrow right"></span></div><div class="link">synchronized<!----></div></a></nav><div class="giscus-wrapper input-top" style="display:block;"></div><!----><!--]--></main><!--]--><footer class="footer-wrapper"><div class="footer"><a href="https://beian.miit.gov.cn/" target="_blank">豫ICP备2021038026号-1</a><img src="https://cdn.tobebetterjavaer.com/tobebetterjavaer/images/beian.png" height="15px" width="15px" /><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41030502000411"><span>豫公网安备 41030502000411号</span></a></div><div class="copyright">Copyright © 2022 沉默王二</div></footer><!--]--></div><!--]--><!----><!----><!--]--></div>
    <script type="module" src="/assets/app.795d54da.js" defer></script>
  </body>
</html>