<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ![](https://img.kancloud.cn/41/e0/41e066af9a6c25a24868d9667253ec98_1241x333.jpg) ***** ### 面試題 > 描述Python GIL的概念,以及它對Python多線程的影響 1.主線程死循環 ``` while True: pass ``` 2.2個線程死循環 ~~~ import threading # 子線程死循環 def test(): while True: pass t1 = threading.Thread(target=test) t1.start() # 主線程死循環 while True: pass ~~~ 3.2個進程死循環 ~~~ import multiprocessing def deapLoop(): while True: pass # 子進程死循環 p1 = multiprocessing.Process(target=deapLoop) p1.start() # 主進程死循環 while True: pass ~~~ ### 參考答案 > python語言和GIL沒有關系,僅僅是由于歷史原因在Cpython虛擬機,難以移除GIL > GIL:全局解釋器鎖。每個線程在執行的過程都需要先獲取GIL,保證同一時刻只有一個線程可以執行代碼 > 線程釋放GIL鎖的情況:在IO操作等可能會引起阻塞的system call之前,可以暫時釋放GIL,但在執行完畢后,必須重新獲取GIL,Python3使用計時器 > Python使用多進程是可以利用多核的CPU資源的 > 多線程爬取比單線程性能有提升,因為遇到IO阻塞會自動釋放GIL鎖
                  <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>

                              哎呀哎呀视频在线观看