From: thomas at tada.se (Thomas Hallgren) Date: Thu, 23 Feb 2006 08:58:46 +0100 Subject: [Pljava-dev] Again multithreading In-Reply-To: <803736063@web.de> References: <803736063@web.de> Message-ID: <43FD6B36.1030104@tada.se> Patrick Peisker wrote: > (1) PL/Java uses one JVM per connection. Run the PL/Java trigger functions in one "main" JVM or run the functions in the JVM of the actuator (e.g. a JDBC connection unsing the SQL-statement 'insert')? > > The trigger will be executed in the JVM that becomes embedded in the PostgreSQL backend process that represents the connection. PostgreSQL spawns a new process for each connection that is opened. The JVM becomes part of that process. > (2) What happens to a thread if it is created in a JVM of an conncetion and the connection is closed? > > When the connection is closed, the PostgreSQL backend process terminates and since the JVM is embedded, it terminates too, in a controlled manner. > (3) Referring to my first mail about multihreading, is there any chance to ensure that a thread is called again from the backend? > > No, not unless you do it yourself. If you issue a function call to a Java function and let that function sleep for a short period of time, other threads that are waiting to use the backend will be released. Kind Regards, Thomas Hallgren