To create a Script, use the Parser class to parse a file. Java programs set JavaScript Global properties by adding objects to a HashMap. Typically you will at least assign the 'File' and the 'out' objects. The running script will see these objects as properties of the Global object. Essentially, the effect is similar to the HashMap technique, but it's a little simpler.
Scripts are thread-safe.
Multiple script instances can safely execute in separate threads. Script.execute creates the entire JavaScript global object hierarchy fresh for each execution. So one Script execution cannot interfere with another, even by doing evil things like modifying the Object prototype. Of course, wrapped Java objects shared by script invocations must still be synchronized. Execute the program, returning a closure of the global state.