久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='GEMgQ'></tfoot>
  1. <legend id='GEMgQ'><style id='GEMgQ'><dir id='GEMgQ'><q id='GEMgQ'></q></dir></style></legend>
    <i id='GEMgQ'><tr id='GEMgQ'><dt id='GEMgQ'><q id='GEMgQ'><span id='GEMgQ'><b id='GEMgQ'><form id='GEMgQ'><ins id='GEMgQ'></ins><ul id='GEMgQ'></ul><sub id='GEMgQ'></sub></form><legend id='GEMgQ'></legend><bdo id='GEMgQ'><pre id='GEMgQ'><center id='GEMgQ'></center></pre></bdo></b><th id='GEMgQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GEMgQ'><tfoot id='GEMgQ'></tfoot><dl id='GEMgQ'><fieldset id='GEMgQ'></fieldset></dl></div>

    <small id='GEMgQ'></small><noframes id='GEMgQ'>

        <bdo id='GEMgQ'></bdo><ul id='GEMgQ'></ul>

      跨集群共享 Java 同步塊,還是使用全局鎖?

      Sharing a Java synchronized block across a cluster, or using a global lock?(跨集群共享 Java 同步塊,還是使用全局鎖?)
        <bdo id='BKx3g'></bdo><ul id='BKx3g'></ul>
        <i id='BKx3g'><tr id='BKx3g'><dt id='BKx3g'><q id='BKx3g'><span id='BKx3g'><b id='BKx3g'><form id='BKx3g'><ins id='BKx3g'></ins><ul id='BKx3g'></ul><sub id='BKx3g'></sub></form><legend id='BKx3g'></legend><bdo id='BKx3g'><pre id='BKx3g'><center id='BKx3g'></center></pre></bdo></b><th id='BKx3g'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BKx3g'><tfoot id='BKx3g'></tfoot><dl id='BKx3g'><fieldset id='BKx3g'></fieldset></dl></div>

        1. <small id='BKx3g'></small><noframes id='BKx3g'>

                  <tbody id='BKx3g'></tbody>

                <legend id='BKx3g'><style id='BKx3g'><dir id='BKx3g'><q id='BKx3g'></q></dir></style></legend>
              • <tfoot id='BKx3g'></tfoot>
                本文介紹了跨集群共享 Java 同步塊,還是使用全局鎖?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一些代碼只允許一個線程訪問.我知道如何使用 synchronized 塊或方法來完成此操作,但這是否適用于集群環境?

                I have some code that I want to only allow access to by one thread. I know how to accomplish this using either synchronized blocks or methods, but will this work in a clustered environment?

                目標環境為 WebSphere 6.0,集群中有 2 個節點.

                The target environment is WebSphere 6.0, with 2 nodes in the cluster.

                我感覺 synchronized 行不通,因為每個節點上的應用程序的每個實例都會有自己的 JVM,對吧?

                I have a feeling that synchronized won't work, since each instance of the application on each node will have its own JVM, right?

                我在這里嘗試做的是在系統啟動時對數據庫記錄進行一些更新.它將查找比代碼版本更舊的任何數據庫記錄,并執行特定任務來更新它們.我只希望一個節點來執行這些升級,因為我想確保每個工作項只升級一次,并且這些升級的性能不是一個大問題,因為它只發生在應用程序啟動時,它只是真正做任何事情自上次啟動以來代碼已更改的時間.

                What I am trying to do here is perform some updates to database records when the system is booted. It will look for any database records that are older that the version of the code, and perform specific tasks to update them. I only want one node to perform these upgrades, since I want to be sure that each work item is only upgraded once, and performance of these upgrades is not a big concern, since it only happens at application startup, and it only really does anything when the code has been changed since the last time it started up.

                數據庫是DB2v9,我直接通過JNDI(無ORM層)訪問.

                The database is DB2v9, and I am accessing it directly via JNDI (no ORM layer).

                有人建議在這里使用全局鎖,但我不知道該怎么做.

                It has been suggested that a global lock might be the way to go here, but I'm not sure how to do that.

                有沒有人指點一下這個領域?

                Does anyone have any pointers in this arena?

                謝謝!

                推薦答案

                您是正確的,跨進程同步將無法使用 Java 同步構造.幸運的是,您的問題實際上不是代碼同步問題,而是與數據庫的交互同步問題.

                You are correct that synchronization across processes will not work using the Java synchronization constructs. Fortunately, your problem really isn't one of code synchronization, but rather of synchronizing interactions with the database.

                處理這個問題的正確方法是使用數據庫級鎖.假設您有一些包含 db 架構版本的表,因此您應該確保在啟動/升級過程中鎖定該表.

                The right way to deal with this problem is with database level locks. Presumably you have some table that contains a db schema version, so you should make sure to lock that table for the duration of the startup/upgrade process.

                如果您指定數據庫類型(DB2?)和訪問方法(原始 sql、jpa 等),所涉及的精確 sql/db 調用可能會更清楚.

                The precise sql/db calls involved would probably be more clear if you specified your database type (DB2?) and access method (raw sql, jpa, etc).

                更新(2009 年 8 月 4 日下午 2:39):我建議使用 LOCK TABLE 對一些持有模式版本號的表的聲明.這將序列化對該表的訪問,防止兩個實例同時運行升級代碼.

                Update (8/4/2009 2:39PM): I suggest the LOCK TABLE statement on some table holding the version # of the schema. This will serialize access to that table preventing two instances from running through the upgrade code at once.

                這篇關于跨集群共享 Java 同步塊,還是使用全局鎖?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數轉換為整數?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                <i id='8ke3G'><tr id='8ke3G'><dt id='8ke3G'><q id='8ke3G'><span id='8ke3G'><b id='8ke3G'><form id='8ke3G'><ins id='8ke3G'></ins><ul id='8ke3G'></ul><sub id='8ke3G'></sub></form><legend id='8ke3G'></legend><bdo id='8ke3G'><pre id='8ke3G'><center id='8ke3G'></center></pre></bdo></b><th id='8ke3G'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8ke3G'><tfoot id='8ke3G'></tfoot><dl id='8ke3G'><fieldset id='8ke3G'></fieldset></dl></div>
                      • <bdo id='8ke3G'></bdo><ul id='8ke3G'></ul>

                        <small id='8ke3G'></small><noframes id='8ke3G'>

                        <tfoot id='8ke3G'></tfoot>
                        <legend id='8ke3G'><style id='8ke3G'><dir id='8ke3G'><q id='8ke3G'></q></dir></style></legend>

                          <tbody id='8ke3G'></tbody>

                          主站蜘蛛池模板: 国产激情视频在线免费观看 | 中文字幕一区二区三区四区五区 | 国产精品成av人在线视午夜片 | 国产精品小视频在线观看 | av黄色免费在线观看 | 日韩精品在线网站 | 亚洲欧美日韩精品久久亚洲区 | 91在线看片| 久久草在线视频 | 红桃视频一区二区三区免费 | 日韩欧美在线观看视频 | 国产成人久久av免费高清密臂 | 亚洲视频中文字幕 | 中文字幕av第一页 | 国产精久久久久久 | 亚洲欧美久久 | 国产农村妇女精品一二区 | 国产成人精品a视频一区www | 国产综合一区二区 | 九九久久精品 | 日韩视频精品在线 | 午夜精品久久久久99蜜 | 欧美 日韩 国产 一区 | 视频在线一区二区 | 羞羞网站在线免费观看 | 久久精品一区 | 欧美成人a∨高清免费观看 老司机午夜性大片 | av毛片 | 中文字幕亚洲区 | 国产欧美一区二区三区在线看蜜臀 | 99精品一区 | 亚洲一区毛片 | 婷婷久久综合 | 在线看片网站 | 国产亚洲精品久久19p | 一二三四在线视频观看社区 | 国产色网 | 精品在线观看一区 | 97精品超碰一区二区三区 | 成人一级黄色毛片 | 四虎首页|