Interface CpuBound

All Superinterfaces:
Runnable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CpuBound extends Runnable
CPU-Bound Marker Interface CPU 密集型标记接口

A marker interface for Runnable tasks that are CPU-bound. When submitted to a HybridExecutor, tasks implementing this interface will be dispatched to the platform thread pool instead of the virtual thread pool.

用于标记 CPU 密集型 Runnable 任务的标记接口。 当提交到 HybridExecutor 时,实现此接口的任务将被分派到平台线程池而非虚拟线程池。

Example | 示例:

CpuBound heavyTask = () -> {
    // CPU-intensive computation
    computeHash(data);
};

try (var executor = HybridExecutor.create()) {
    executor.execute(heavyTask); // dispatched to platform thread pool
}

Features | 主要功能:

  • Marker interface for CPU-bound tasks - CPU密集型任务的标记接口
  • Automatic dispatch to platform thread pool - 自动分派到平台线程池
  • Functional interface support - 函数式接口支持

Security | 安全性:

  • Thread-safe: Implementation dependent - 线程安全: 取决于实现
Since:
JDK 25, opencode-base-parallel V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Methods inherited from interface Runnable

    run