@Test public void replaceThreadNameWith() throws Exception { AtomicBoolean hasRun = new AtomicBoolean(false); Runnable runnable = AnnotatedRunnable.replaceThreadNameWith("test thread name", () -> { assertThat(Thread.currentThread().getName(), is("test thread name")); hasRun.set(true); }); runnable.run(); assertThat(hasRun.get(), is(true)); }
public static Runnable replaceThreadNameWith(String threadName, Runnable delegate) { return wrapWithThreadName(AnnotationType.REPLACE, threadName, delegate); }
AnnotatedRunnable implements Runnable { public static Runnable replaceThreadNameWith(String threadName, Runnable delegate) { return wrapWithThreadName(AnnotationType.REPLACE, threadName, delegate); } }
AnnotatedRunnable implements Runnable { public static Runnable replaceThreadNameWith(String threadName, Runnable delegate) { return wrapWithThreadName(AnnotationType.REPLACE, threadName, delegate); } private  AnnotatedRunnable(Runnable delegate, String name, AnnotationType type); }
AnnotatedRunnable implements Runnable { public static Runnable replaceThreadNameWith(String threadName, Runnable delegate) { return wrapWithThreadName(AnnotationType.REPLACE, threadName, delegate); } private  AnnotatedRunnable(Runnable delegate, String name, AnnotationType type); static Runnable replaceThreadNameWith(String threadName, Runnable delegate); static Runnable wrapWithThreadName(AnnotationType type, String threadName, Runnable delegate); @Override void run(); }
AnnotatedRunnable implements Runnable { public static Runnable replaceThreadNameWith(String threadName, Runnable delegate) { return wrapWithThreadName(AnnotationType.REPLACE, threadName, delegate); } private  AnnotatedRunnable(Runnable delegate, String name, AnnotationType type); static Runnable replaceThreadNameWith(String threadName, Runnable delegate); static Runnable wrapWithThreadName(AnnotationType type, String threadName, Runnable delegate); @Override void run();  }