<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 類加載機制 ## 類的生命周期 ![](https://img.kancloud.cn/e7/7c/e77c94884093de5ed80add9fba016160_1334x1580.png) ## 加載 ![](https://img.kancloud.cn/ae/7d/ae7dde46037a8e9083ef22bfcd8a23d9_962x892.png) ## 驗證 文件格式驗證,元數據驗證(語義校驗),字節碼驗證(邏輯校驗),符號引用校驗 ![](https://img.kancloud.cn/9b/04/9b0405fa4123ca68f119de3f0f4a80da_1236x724.png) ## 準備 為類變量(static的)分配內存并賦初始值。 ![](https://img.kancloud.cn/74/12/741218b305c5926f2212ed6c081ce3ec_1060x498.png) ## 解析 主要針對: * 類或接口:CONSTANT_Class_info * 字段:CONSTANT_Fieldref_info * 類方法:CONSTANT_Methodref_info * 接口方法:CONSTANT_InterfaceMethodref_info (以下3種,是JDK1.7新增的動態語言支持,后續介紹) * 方法類型:CONSTANT_MethodType_info * 方法句柄:CONSTANT_MethodHandle_info * 調用點限定符:CONSTANT_InvokeDynamic_info ![](https://img.kancloud.cn/c6/ed/c6ed780411c43bc91bc21930e85d140d_698x484.png) ## 初始化 ![](https://img.kancloud.cn/42/68/4268d22e33b874e0fc77e47799790ca7_602x328.png) ![](https://img.kancloud.cn/04/12/041280c062142b247986c357e56235fa_710x316.png) 測試: ~~~ /** * 死循環類 * @Author: mango * @Date: 2022/6/19 10:54 上午 */ public class DeadLoopClass { static { if(true){ System.out.println(Thread.currentThread() + " init DeadLoopClass"); while (true){ // 模擬長時間操作 } } } } ~~~ ~~~ /** * 類加載及初始化測試 * @Author: mango * @Date: 2022/6/19 10:58 上午 */ public class ClassInitTest { public static void main(String[] args) { Runnable runnable = new Runnable() { @Override public void run() { System.out.println(Thread.currentThread() + " start"); DeadLoopClass dlc = new DeadLoopClass(); System.out.println(Thread.currentThread() + " end"); } }; Thread t1 = new Thread(runnable); Thread t2 = new Thread(runnable); t1.start(); t2.start(); } } /** * 結果:第一個線程會卡主,其他線程阻塞 * Thread[Thread-0,5,main] start * Thread[Thread-1,5,main] start * Thread[Thread-0,5,main] init DeadLoopClass */ ~~~ ## 卸載 類卸載需要滿足如下條件: * 該類所有的實例都已經被回收。 * 加載該類的ClassLoader已經被回收。 * 該類對應的java.lang.Class對象沒有任何地方被引用。 ## 參考資料 * 周志明 * 《深入理解Java虛擬機》
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看