That solution works only for interpreters that need another system state. It does not work for interpreters that should use different pre and post properties or command line arguments, because the initialize methods on PythonInterpreter and PySystemState are static methods that do nothing when initialization already happened before. In particular, using two instances of PythonInterpreter with different class paths is not possible.
 
Regards,
RR
-----Original Message-----
From: jython-users-admin@lists.sourceforge.net [mailto:jython-users-admin@lists.sourceforge.net] On Behalf Of Jeff Emanuel
Sent: Thursday, October 07, 2004 6:42 PM
To: Perez Carmona, David
Cc: jython-users@lists.sourceforge.net
Subject: RE: [Jython-users] Global Jython state

Construct your interpreters with there own instances of PySystemState.
Use the constructor that takes two arguments:
 
    public PythonInterpreter(new PyStringMap(), new PySystemState());
-----Original Message-----
From: jython-users-admin@lists.sourceforge.net [mailto:jython-users-admin@lists.sourceforge.net] On Behalf Of Perez Carmona, David
Sent: Thursday, October 07, 2004 9:35 AM
To: JyUsr (E-mail)
Subject: [Jython-users] Global Jython state

Dear Jythoners,
 
If I create in several threads different PythonInterpreter
 
Thread1
 
    PythonInterpreter py = new PythonInterpreter();
    py.setOut(stream1);
    py.exec("print 'hi 1'");
 
 
Thread2
 
    PythonInterpreter py = new PythonInterpreter();
    py.setOut(stream2);
    py.exec("print 'hi 2'");
 
The result is that both messages a printed to stream1, instead of separated streams.
Is PySystemState shared between all threads?.
Any hint will be greatly appreciated.
 
Regards,
David