public void schedule(JSObject aJsTask, long aTimeout) { Scripts.LocalContext context = Scripts.getContext(); bio.submit( () -> { try { Thread.sleep(aTimeout); Scripts.setContext(context); try { process( () -> { aJsTask.call(null, new Object[] {}); }); } finally { Scripts.setContext(null); } } catch (InterruptedException ex) { Logger.getLogger(Scripts.class.getName()).log(Level.SEVERE, null, ex); } }); }
public void enqueue(JSObject aJsTask) { process( () -> { aJsTask.call(null, new Object[] {}); }); }