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

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

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

    懵懵燈燈的BLOG

    寒夜孤燈點點星

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      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問題歸根結底是該類和方法是否可重入,re-entrance.

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

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


    網站導航:
     
    主站蜘蛛池模板: 91亚洲精品第一综合不卡播放| 亚洲国产香蕉人人爽成AV片久久 | 老司机午夜性生免费福利| www.999精品视频观看免费| 亚洲色av性色在线观无码| 蜜桃成人无码区免费视频网站 | 黄色短视频免费看| 亚洲午夜福利精品久久| a一级爱做片免费| 亚洲中文字幕久久精品无码APP| 国产精品无码免费专区午夜| 久久亚洲高清综合| 黄色免费在线网站| 亚洲黄色在线观看网站| 最近高清中文字幕无吗免费看| 亚洲一区免费视频| 国产老女人精品免费视频 | 成全动漫视频在线观看免费高清版下载 | 免费无码AV电影在线观看| 亚洲日本va一区二区三区| 国产一级淫片a视频免费观看| 思思久久99热免费精品6| 狠狠亚洲婷婷综合色香五月排名 | a毛片成人免费全部播放| 亚洲欧洲精品无码AV| 三年片在线观看免费大全电影 | 亚洲精品国产国语| 国产免费131美女视频| 毛片基地看看成人免费| 亚洲成人精品久久| 免费国产作爱视频网站| 国产精品亚洲一区二区无码| 亚洲日韩v无码中文字幕| 黄色成人免费网站| 免费国产草莓视频在线观看黄| 亚洲国产精品VA在线观看麻豆 | 100部毛片免费全部播放完整| 亚洲精品无码永久在线观看男男 | 久久久久亚洲AV无码麻豆| 国产成人精品男人免费| 免费播放在线日本感人片|