Class NamedThreadFactory

java.lang.Object
cloud.opencode.base.core.thread.NamedThreadFactory
All Implemented Interfaces:
ThreadFactory

public class NamedThreadFactory extends Object implements ThreadFactory
Named Thread Factory - Custom thread factory with naming support 命名线程工厂 - 支持自定义命名的线程工厂

ThreadFactory implementation with configurable naming, daemon, and priority settings.

线程工厂实现,支持配置命名、守护进程和优先级。

Features | 主要功能:

  • Custom thread name prefix with auto-numbering - 自定义线程名前缀和自动编号
  • Daemon thread configuration - 守护线程配置
  • Thread priority configuration - 线程优先级配置
  • Builder pattern support - 构建器模式支持

Usage Examples | 使用示例:

// Simple factory - 简单工厂
ThreadFactory factory = new NamedThreadFactory("worker");

// Daemon factory - 守护线程工厂
ThreadFactory daemon = NamedThreadFactory.daemon("background");

// Builder pattern - 构建器模式
ThreadFactory custom = NamedThreadFactory.builder()
    .namePrefix("task")
    .daemon(true)
    .priority(Thread.MAX_PRIORITY)
    .build();

Security | 安全性:

  • Thread-safe: Yes (AtomicInteger counter) - 线程安全: 是
  • Null-safe: No (requires name prefix) - 空值安全: 否
Since:
JDK 25, opencode-base-core V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • NamedThreadFactory

      public NamedThreadFactory(String namePrefix)
    • NamedThreadFactory

      public NamedThreadFactory(String namePrefix, boolean daemon)
    • NamedThreadFactory

      public NamedThreadFactory(String namePrefix, boolean daemon, int priority)
  • Method Details