- We still think threading is tricky. Basically, we kept adding
synchronizedto places until everything worked. Effective Java says that you shouldn't add
- The basic problem was this: when executing long commands, the js interpreter grabbed the main thread, and things locked up.
- We solved this by replacing the js environment with a js thread, which in turn initialized the environment.
- After that change, commands were executed, but couldn't print things back to the js console.
- So, we devised a mechanism for sending the js thread a "post-command hook" along with the js command. The post-command hook is a piece of code that the js thread executes after it has executed the js command. Sending code as parameters is exciting!
- Normally, one puts such code into an anonymous
Runnablesubclass, but we couldn't do that, since
Runnable.run()doesn't take a parameter, and we needed to send a parameter to our hook. So we invented our own class,