java scripting API - how to stop the evaluation

后端 未结 7 1647
孤城傲影
孤城傲影 2020-12-09 06:10

i have writen a servlet that recives a java script code and process it and returns the answer. for that i have used the java scripting API

in the code below if scrip

7条回答
  •  萌比男神i
    2020-12-09 07:10

    Nashorn scripts are compiled to .class "files" & loaded on the fly. So, script evaluation is similar to loading a compiled Java .class and running the same. Unless you program explicitly for interruption, you can't stop script evaluation. There is no "script interpreter" that "polls" for interrupt status. You've to explicitly call Thread.sleep or other Java API that be interrupted from another thread.

提交回复
热议问题