锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品视频在线观看网站,3d成人动漫在线,91精品影视http://www.aygfsteel.com/mmmyddd/category/26834.html<font color="olive">瀵掑瀛ょ伅鐐圭偣鏄?lt;/color>zh-cnThu, 15 May 2008 06:57:32 GMTThu, 15 May 2008 06:57:32 GMT60Java GUI 涓殑綰跨▼瀹夊叏闂http://www.aygfsteel.com/mmmyddd/archive/2008/05/14/200475.html鎳墊嚨鐏伅鎳墊嚨鐏伅Wed, 14 May 2008 12:42:00 GMThttp://www.aygfsteel.com/mmmyddd/archive/2008/05/14/200475.htmlhttp://www.aygfsteel.com/mmmyddd/comments/200475.htmlhttp://www.aygfsteel.com/mmmyddd/archive/2008/05/14/200475.html#Feedback0http://www.aygfsteel.com/mmmyddd/comments/commentRss/200475.htmlhttp://www.aygfsteel.com/mmmyddd/services/trackbacks/200475.html From錛歨ttp://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 -
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'