@Test
    public void shouldNotInterruptWhile() throws Exception {
        // companion to shouldInterruptWhile                                 t
        final ScriptEngine engine = new GremlinGroovyScriptEngine();
        final AtomicBoolean exceptionFired = new AtomicBoolean(true);

        final Thread t = new Thread(() -> {
            try {
                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {};'test'");
                exceptionFired.set(false);
            } catch (ScriptException se) {
                se.printStackTrace();
            }
        });

        t.start();
        Thread.sleep(100);
        t.interrupt();
        while(t.isAlive()) {}

        assertFalse(exceptionFired.get());
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java