JNI again

Robert S. Thau rst at ai.mit.edu
Wed Aug 13 08:25:36 PDT 1997


Daniel Dittmar writes:

 > Another reason why Kaffe should support JNI or something similar:
 > I would like to embed Kaffe in a server. As requests are handled in
 > parallel, Java VMs should be independant of another.

Umm... this does not necessarily follow.  In particular, Sun's servlet
server extension API runs different requests as different *threads* in
the same VM.  This allows simultaneous requests to be handled
independantly of each other, if that's what the programmer wants; just
avoid shared data structure (i.e., static attributes on the servlet or
related classes).

However, it also allows a server extension to accumulate information
on its history, the state of outstanding requests, and so forth, in a
manner which would be a great deal more difficult if different
instances of the extension were walled off in separate VMs (which
means, in principle, separate address spaces).  To take a trivial
example, a "this page viewed XXX times" counter is trivial to write
with single-VM, multiple threads, and rather more difficult to write
otherwise (since different instances must interact through means
outside the VM, such as the filesystem).  

Also, multiple-threads-in-single-VM allows significant saving of
resources (say, one open JDBC connection shared by all requests to a
given server extension, as opposed to one per VM --- assuming proper
synchronization, of course, but a bug-free JDBC driver is *supposed*
to take care of this automatically).

rst



More information about the kaffe mailing list