Hi, According to: http://docs.groovy-lang.org/latest/html/documentation/guide-integrating.html
“You must be very careful when using shared data in a multithreaded environment. The Binding instance that you pass to GroovyShell is not thread safe, and shared by all scripts.” There are some guidelines regarding multi-threading and thread-safety. Before attempting something like this, ask yourself the question, “can I guarantee that my code is thread safe?”, which is very different from running a successful test without concurrency issues. You could use the GroovyClassLoader directly and keep the compiled scripts in a cache, see the mentioned docs on how to obtain thread-safety with the Binding object. From: K Adithyan (tech) [mailto:adi.k....@gmail.com] Sent: Wednesday, February 7, 2018 4:15 PM To: users@groovy.apache.org Subject: Executing Groovy DSL scripts concurrently Team, Our application is a Root Cause Analysis Computation Engine for Telecom networks. We have been implementing the logics in java only so far. We are now planning to write DSLs for each feature and write the logics using the DSL. We have implemented a framework for plugging in any number of DSLs and integrated that DSL Framework with our application. Each of the logics written over the DSL are executed concurrently using 40 or 50 or 60 threads based on the rate of the incoming events. Due to the concurrency, we are now creating `GroovyShell` object for every execution and calling `shell.evaluate(ourScriptFile)` to run the DSL scripts with our own Binding object and delegates. This prevents the system to run the logic at its own speed. Everytime parsing and running takes significant time which reduces the event handling capacity of the application. I have attempted with `GroovyShell` and `GroovyScriptEngine`. But both are offering same performance levels. GroovyShell is slightly better than GroovyScriptEngine. Under these circumstances, what is the best way to wrap our script logic, that is based on our own DSLs, and run it concurrently without any overhead for parsing, compilation, etc????????? Pls advice Reg, Adithyan K This e-mail message contains confidential information and is intended only for the named recipient(s). If you are not an intended recipient, any disclosure, copying or distribution is prohibited. Please notify the sender immediately by e-mail if you have received this message in error and delete this message from your system. As internet communications are not secure, the Swiss National Bank accepts no liability for any errors or omissions in the contents of this message. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Swiss National Bank.