ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Executors.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/Executors.java (file contents):
Revision 1.55 by dl, Wed May 25 14:05:27 2005 UTC vs.
Revision 1.56 by dl, Thu May 26 12:07:14 2005 UTC

# Line 337 | Line 337 | public class Executors {
337       * @return a callable object
338       * @throws NullPointerException if action null
339       */
340 <    public static Callable<Object> callable(PrivilegedAction<?> action) {
340 >    public static Callable<Object> callable(final PrivilegedAction<?> action) {
341          if (action == null)
342              throw new NullPointerException();
343 <        return new PrivilegedActionAdapter<Object>(action);
343 >        return new Callable<Object>() {
344 >            public Object call() { return action.run(); }};
345      }
346  
347      /**
# Line 351 | Line 352 | public class Executors {
352       * @return a callable object
353       * @throws NullPointerException if action null
354       */
355 <    public static Callable<Object> callable(PrivilegedExceptionAction<?> action) {
355 >    public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) {
356          if (action == null)
357              throw new NullPointerException();
358 <        return new PrivilegedExceptionActionAdapter<Object>(action);
358 >        return new Callable<Object>() {
359 >            public Object call() throws Exception { return action.run(); }};
360      }
361  
362      /**
# Line 420 | Line 422 | public class Executors {
422      }
423  
424      /**
423     * A callable that runs given privileged action and returns its result
424     */
425    static final class PrivilegedActionAdapter<T> implements Callable<Object> {
426        PrivilegedActionAdapter(PrivilegedAction action) {
427            this.action = action;
428        }
429        public Object call () {
430            return action.run();
431        }
432        private final PrivilegedAction action;
433    }
434
435    /**
436     * A callable that runs given privileged exception action and returns its result
437     */
438    static final class PrivilegedExceptionActionAdapter<T> implements Callable<Object> {
439        PrivilegedExceptionActionAdapter(PrivilegedExceptionAction action) {
440            this.action = action;
441        }
442        public Object call () throws Exception {
443            return action.run();
444        }
445        private final PrivilegedExceptionAction action;
446    }
447
448
449    /**
425       * A callable that runs under established access control settings
426       */
427      static final class PrivilegedCallable<T> implements Callable<T> {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines