Skip to content

Java Virtual Thread Support #31

@barisyild

Description

@barisyild

An optional virtual thread support can be added for the Java target. (JDK 21+)

Here is extern:

package jvm.lang;

import java.lang.Runnable;

@:native("java.lang.Thread")
extern class Thread {
    public static function startVirtualThread(task:Job):Thread;

    public static function currentThread():Thread;

    public function isVirtual():Bool;
}

private abstract Job(Runnable) from Runnable to Runnable {
    public inline function new(job:() -> Void) {
        this = cast job;
    }
}

System Thread implementation: https://github.com/HaxeFoundation/haxe/blob/cefabb12021d27ab56ed3f1c75667318831f09f6/std/jvm/_std/sys/thread/Thread.hx

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions