Wrap a Runnable so that it executes with this context as the #current context.
(final Runnable r)
| 558 | * Wrap a {@link Runnable} so that it executes with this context as the {@link #current} context. |
| 559 | */ |
| 560 | public Runnable wrap(final Runnable r) { |
| 561 | return new Runnable() { |
| 562 | @Override |
| 563 | public void run() { |
| 564 | Context previous = attach(); |
| 565 | try { |
| 566 | r.run(); |
| 567 | } finally { |
| 568 | detach(previous); |
| 569 | } |
| 570 | } |
| 571 | }; |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * Wrap a {@link Callable} so that it executes with this context as the {@link #current} context. |
no outgoing calls