jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
changeset 2817 f171f2417978
parent 2489 5052722686e2
child 3346 1c65be97eaa2
equal deleted inserted replaced
2816:847399d5b5e9 2817:f171f2417978
   476             return comThread;
   476             return comThread;
   477         }
   477         }
   478 
   478 
   479         public <T> T invoke(Callable<T> task) {
   479         public <T> T invoke(Callable<T> task) {
   480             try {
   480             try {
   481                 T result;
       
   482                 if (Thread.currentThread() == comThread) {
   481                 if (Thread.currentThread() == comThread) {
   483                     // if it's already called from the COM
   482                     // if it's already called from the COM
   484                     // thread, we don't need to delegate the task
   483                     // thread, we don't need to delegate the task
   485                     result = task.call();
   484                     return task.call();
   486                 } else {
   485                 } else {
   487                     Future<T> future = submit(task);
   486                     while (true) {
   488                     try {
   487                         Future<T> future = submit(task);
   489                         result = future.get();
   488 
   490                     } catch (InterruptedException e) {
   489                         try {
   491                         result = null;
   490                             return future.get();
   492                         future.cancel(true);
   491                         } catch (InterruptedException e) {
   493                     }
   492                             // Repeat the attempt
   494                 }
   493                             future.cancel(true);
   495                 return result;
   494                         }
       
   495                     }
       
   496                 }
   496             } catch (Exception e) {
   497             } catch (Exception e) {
   497                 Throwable cause = (e instanceof ExecutionException) ? e.getCause() : e;
   498                 Throwable cause = (e instanceof ExecutionException) ? e.getCause() : e;
   498                 if (cause instanceof RuntimeException) {
   499                 if (cause instanceof RuntimeException) {
   499                     throw (RuntimeException) cause;
   500                     throw (RuntimeException) cause;
   500                 }
   501                 }