CNI threads and garbage collection on FC4

Andi Vajda andi@osafoundation.org
Fri Aug 26 23:01:00 GMT 2005


> When you say after the fact, after what exactly do you mean?

Sorry, I should have been clearer. You cannot create a thread on your own, the 
thread *must* be created by Java. By after the fact, I mean creating a thread 
on your own, in C for example, and then hoping to use that thread from Java.
> that includes an example of calling java from a C++ thread. It seems
> like the JvAttachCurrentThread(NULL, NULL) function serves no purpose if
> it can't be used to attach other threads to the JVM.

Agreed.
> Do you mean it only works if you call java code from the main thread,
> but not from threads created by pthread_create?

The thread must be created by Java, it cannot be created directly by you using 
pthread_create() or otherwise.
> If so, I don't need garbage collection, I'm happy to delete the objects
> manually. I just need to call
> java::io::ObjectOutputStream::writeObject() from a C++ thread. Can I
> tell the garbage collector not to run somehow?

I don't think so. As soon as Java allocates an object, the gc is involved and, 
if the thread wasn't created by it, your process will crash.
Andi..


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /