Use cores with isolates
An isolate runs a named top-level function in parallel on an OS thread. Its mutable state is separate from the caller's. Plain data crosses by copy through arguments, results, or isolate channels.
Functions, futures, channels, and pointers cannot cross. Worker output is replayed as one block at join, so output is deterministic in join order. Thread creation is local-only here.
fn square(value: int) -> int { value * value }
fn main() {
let worker = std.isolate.spawn("square", [6])
println(std.isolate.join(worker))
}
Examples use the moon toolchain version shown beside each result.
Run locally
moon run main.mn
Ctrl/⌘+Enter checks the current lesson.