All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.plugin.js.JSTimerTask Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.plugin.js;

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

import java.util.TimerTask;

public final class JSTimerTask extends TimerTask {
    private final long id;
    private final Context jsContext;
    private final Value callback;
    private final Object[] args;

    public JSTimerTask(long id, Context jsContext, Value callback, Object... args) {
        this.id = id;
        this.jsContext = jsContext;
        this.callback = callback;
        this.args = args;
    }

    @Override
    public void run() {
        synchronized (jsContext) {
            if (callback != null && callback.canExecute()) {
                callback.executeVoid(args);
            }
        }
    }

    public long getId() {
        return id;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy