Subj : Re: Multithreading and Rhino To : Josh G From : Igor Bukanov Date : Mon Sep 22 2003 10:11 am Josh G wrote: > Hi, I don't know if this is the right place to ask, but I will anyway - > can anybody point me to some good documentation / examples on using > Rhino in multithreaded environments? Specifically we're going to be > extending our web application with javascript for some events, and we're > trying to create a shared pool of Context objects so we don't have to > create one of every request that comes in. You should NEVER cache Context objects and always use the following 2 patterns when using them: Context cx = Context.enter(); try { Code that use context. } finally { Context.exit(); } or when using a custom Context subclass: Context cx = Context.enter(new ContexSubclass(...)); try { Any code that use context. } finally { Context.exit(); } Context does not store any objects except function activations records during script evaluation, it is a scope that does. > > Any pointers much appreciated. See http://mozilla.org/rhino/scopes.html and examples there how you can setup a shared scope that you can reuse for many threads/web clients. You can also search this thread for, say Context.enter, to get some additional information. Regards, Igor .