┌───────────────────────────────────────────┐ │Fiber │ ├───────────────────────────────────────────┤ │Executor scheduler; // 调度器 │ │FiberScope scope; // 关联的 FiberScope │ ┌───────────────────┐ │Thread carrierThread; // 执行线程 │ │Thread │ │Continuation cont; // 关联的 Continuation │ ├───────────────────┤ │Runnable runContinuation; // 调度执行的逻辑│ │Fiber fiber; │ │ short state; // Fiber 状态 │ │FiberScope scope; │ │ Object result; // 执行结果 │ │Continuation cont; │ │ +awaitTermination(); │ └───────────────────┘ │+cancel(); │ | │+join(); │ | └───────────────────────────────────────────┘ | | | ┌──────────────────────────────────────────────────────────────────┐ ┌────────────────────────────────────────┐ │FiberScope │ │Continuation │ ├──────────────────────────────────────────────────────────────────┤ ├────────────────────────────────────────┤ │Thread owner; │ │ContinuationScope scope; │ │FiberScope parent; │ │Runnable target; │ │{static} FiberScope open(); │ │{static} yield(ContinuationScope scope);│ │Fiber schedule(Runnable task); │ │run(); │ │Fiber schedule(Executor scheduler, Runnable task); │ └────────────────────────────────────────┘ │Fiber schedule(Callable task); │ | │Fiber schedule(Executor scheduler, Callable task);│ | └──────────────────────────────────────────────────────────────────┘ | ┌─────────────────┐ │ContinuationScope│ ├─────────────────┤ │String name; │ └─────────────────┘