コード例 #1
0
 /**
  * A new method that interrupts the worker thread. Call this method to force the worker to stop
  * what it's doing.
  */
 public void interrupt() {
   Thread t = threadVar.get();
   if (t != null) {
     t.interrupt();
   }
   threadVar.clear();
 }
コード例 #2
0
 /**
  * Return the value created by the <code>construct</code> method. Returns null if either the
  * constructing thread or the current thread was interrupted before a value was produced.
  *
  * @return the value created by the <code>construct</code> method
  */
 public Object get() {
   while (true) {
     Thread t = threadVar.get();
     if (t == null) {
       return getValue();
     }
     try {
       t.join();
     } catch (InterruptedException e) {
       Thread.currentThread().interrupt(); // propagate
       return null;
     }
   }
 }
コード例 #3
0
 /** Start the worker thread. */
 public void start() {
   Thread t = threadVar.get();
   if (t != null) {
     t.start();
   }
 }
コード例 #4
0
ファイル: SwingWorker.java プロジェクト: wk8910/phyutility
 /** Allows the priority of the worker thread to be set. */
 public void setPriority(int priority) {
   threadVar.get().setPriority(priority);
 }