Recently, I created a JavaScript library named jsandbox. jsandbox is used for evaluating JavaScript code safely in a sandbox. jsandbox uses web worker threads to do this.
The API for using the jsandbox library is described in detail and with an example on the project page.