<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    懵懵燈燈的BLOG

    寒夜孤燈點點星

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      56 隨筆 :: 10 文章 :: 22 評論 :: 0 Trackbacks
    線程安全問題:

    From:http://www.jguru.com/faq/view.jsp?EID=131370


    Question - Please explain why Swing is not thread safe and AWT is.

    Answer
    Simple answer is - "that's the design choice the Swing team made". It is a well-known fact that writing thread safe API/library is more difficult and inefficient.

    So to simplify the implementation of Swing library they chose it to be not thread safe. The argument being that most of the GUI related work happens in the callbacks from the GUI which happen on the single GUI thread anyways. Granted - for long running tasks the user will have to do more work if he/she wants to do multithreaded activity. Not making Swing thread safe allowed them to implement the Swing which covered a lot more ground (new controls, layouts, keyboard actions, layered pane etc) in a short amount of time.

    It is not that bad though - Swing does provide a mechanism to deal with the issues of threading -

    • javax.swing.SwingUtilities.invokeLater(Runnable ...);
    • javax.swing.SwingUtilities.invokeAndWait(Runnable ...);
    • javax.swing.JProgressBar class
    • javax.swing.ProgressMonitor
    • javax.swing.ProgressMonitorInputStream
    • SwingWorker

    For more explaination of why they made that decision please see the following URLs:

    The AWT is based on the OS's WIndowing System's peer objects which are inherently thread safe. That is why AWT is thread safe.

    One can argue though that they should have provided factory methods (similar to collections framework) or subclasses to get thread safe versions of the Swing classes - for example, TSJTextField or TSJTree where the "TS" stands for 'thread safe'


    另外 , swt和swing一樣都是線程不安全的, 但是java.util.Timer確是安全的,

    thread safe問題歸根結(jié)底是該類和方法是否可重入,re-entrance.

    posted on 2008-05-14 20:42 懵懵燈燈 閱讀(445) 評論(0)  編輯  收藏 所屬分類: Language_Java

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 大陆一级毛片免费视频观看i| 最近中文字幕无免费| 四虎影在线永久免费观看| 亚洲影院天堂中文av色| 91在线视频免费播放| 77777午夜亚洲| 女人毛片a级大学毛片免费| 亚洲精品人成网线在线播放va| 好吊妞998视频免费观看在线| 亚洲精品动漫免费二区| 午夜国产羞羞视频免费网站| 国产精品久久久久久亚洲小说| 国产小视频在线免费| 免费国产va在线观看| 亚洲精品成人网站在线观看 | 亚洲成a∧人片在线观看无码| 女人张开腿等男人桶免费视频| 亚洲av无码专区青青草原| 免费国产在线观看老王影院| 天堂亚洲免费视频| 亚洲国产成人片在线观看| 日本人的色道免费网站| 亚洲国产精品无码久久久秋霞1| 免费真实播放国产乱子伦| 三级黄色免费观看| 亚洲无成人网77777| 国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 | 国产va精品免费观看| 国产产在线精品亚洲AAVV| 亚洲精品制服丝袜四区| 免费国产成人α片| 亚洲精品456人成在线| 四虎影视永久免费观看地址| 四虎影视无码永久免费| 91嫩草亚洲精品| 亚洲av麻豆aⅴ无码电影| 精品熟女少妇a∨免费久久| 亚洲三级高清免费| 亚洲色婷婷综合久久| 性xxxx视频播放免费| 精品成人免费自拍视频|