/** * Get a {@link ThreadFactory} with the required name prefix. The produced * threads are user threads and have normal priority. * * @param name the prefix to use for naming the threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name) { return named(name).build(); }
/** * Schedules the cache cleanup task. */ @EventListener public void onComponentManagerStarted(final ComponentManagerStartedEvent startedEvent) { ScheduledExecutorService e = Executors.newSingleThreadScheduledExecutor(ThreadFactories .named("jira-botocss") .type(DAEMON) .build() ); long cleanupSecs = BotoCssInliner.EXPIRE_SECS / 2; e.scheduleWithFixedDelay(new CacheCleaner(), cleanupSecs, cleanupSecs, SECONDS); executor.set(e); }
/** * Get a {@link ThreadFactory} with the required name prefix and type (user or * daemon). The produced threads have normal priority. * * @param name the prefix to use for naming the threads. * @param type whether they are User or Daemon threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name, @NotNull final Type type) { return named(name).type(type).build(); }
/** * Get a {@link ThreadFactory} with the required name prefix, type and * priority. * * @param name the prefix to use for naming the threads. * @param type whether they are User or Daemon threads. * @param priority the thread priority, must not be lower than * {@link Thread#MIN_PRIORITY} or greater than {@link Thread#MAX_PRIORITY} * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name, @NotNull final Type type, final int priority) { return named(name).type(type).priority(priority).build(); }