Skip to content

Instantly share code, notes, and snippets.

@josmardias
josmardias / setTimeout-nashorn.js
Last active August 23, 2023 21:12 — forked from salomvary/settimeout-nashorn.js
setTimeout polyfill for Nashorn
// https://gist.github.com/josmardias/20493bd205e24e31c0a406472330515a
// at least one timeout needs to be set, larger then your code bootstrap
// or Nashorn will run forever
// preferably, put a timeout 0 after your code bootstrap
(function(context) {
'use strict';
var Timer = Java.type('java.util.Timer');
var Phaser = Java.type('java.util.concurrent.Phaser');