Creates an Executor that renames the Thread threads that its tasks run in. The names are retrieved from the nameSupplier on the thread that is being renamed right before each task is run. The renaming is best effort, if a SecurityManager prevents the renaming then
(
final Executor executor, final Supplier<String> nameSupplier)
| 815 | */ |
| 816 | |
| 817 | @GwtIncompatible // concurrency |
| 818 | static Executor renamingDecorator( |
| 819 | final Executor executor, final Supplier<String> nameSupplier) { |
| 820 | checkNotNull(executor); |
| 821 | checkNotNull(nameSupplier); |
| 822 | if (isAppEngine()) { |
| 823 | // AppEngine doesn't support thread renaming, so don't even try |
| 824 | return executor; |
| 825 | } |
| 826 | return new Executor() { |
| 827 | @Override |
| 828 | public void execute(Runnable command) { |
| 829 | executor.execute(Callables.threadRenaming(command, nameSupplier)); |
| 830 | } |
| 831 | }; |
| 832 | } |
| 833 | |
| 834 | /** |
| 835 | * Creates an {@link ExecutorService} that renames the {@link Thread threads} that its tasks run |
no test coverage detected