<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

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲天堂2016| 亚洲欧美日韩中文字幕在线一区 | 亚洲欧洲日产国码久在线| 免费看片在线观看| 亚洲成a人片在线观看播放| 精品一区二区三区免费毛片爱 | 免费看国产一级特黄aa大片| 亚洲成a人片在线观看天堂无码 | 国产精品无码素人福利免费| 亚洲国产av玩弄放荡人妇| 在线观着免费观看国产黄| 羞羞视频网站免费入口| 精品亚洲视频在线观看| 国产免费AV片在线观看| 久久水蜜桃亚洲av无码精品麻豆| **aaaaa毛片免费同男同女| 亚洲资源最新版在线观看| 亚洲美女大bbbbbbbbb| 午夜免费福利片观看| 亚洲国产精品网站久久| 国产在线19禁免费观看国产| 日韩精品无码免费视频| 亚洲不卡av不卡一区二区| 2015日韩永久免费视频播放| 伊人久久亚洲综合影院首页| 免费国产小视频在线观看| 国产婷婷成人久久Av免费高清| 亚洲人成在线观看| 最近2019中文字幕免费看最新| 国产成人精品亚洲| 亚洲αv在线精品糸列| 无码人妻久久一区二区三区免费丨 | 国内精品免费视频自在线| xvideos永久免费入口| 亚洲综合无码一区二区三区| 波多野结衣久久高清免费| 岛国岛国免费V片在线观看| 亚洲色图.com| 亚洲一级特黄大片无码毛片| 免费人成在线观看69式小视频| 一区免费在线观看|