Which Swing component methods are thread safe?

前端 未结 5 867
情书的邮戳
情书的邮戳 2020-11-27 05:23

According to Swing tutorial:

Some Swing component methods are labelled \"thread safe\" in the API specification; these can be safely invoked from any

5条回答
  •  鱼传尺愫
    2020-11-27 05:28

    But you already have the answer: only those methods which are specifically documented as being thread-safe in the method JavaDoc, are threadsafe! this is from JTextComponent.setText

     * This method is thread safe, although most Swing methods
     * are not. Please see 
     * How
     * to Use Threads for more information.     
    

    If the method documentation doesn't say it's safe, then it isn't safe: access to the JavaDoc is therefore critical when coding against Swing

提交回复
热议问题