This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCJ + Roguewave Threads?


On Sat, 12 Feb 2005 10:35:35 -0500, Bryce McKinlay <mckinlay@redhat.com> wrote:

> Is there any reason why you need to call pthread_exit()?

Only because the LLNL pthreads tutorial, which was my first found
documentation on the issue, recommended it.

> I suggest:
> 
> - Don't call pthread_exit
> - Only JvAttach/JvDetachThread the thread which will be making Java
> calls, not your main thread
> - pthread_join the Java thread you created

This worked relatively well.  I set up a pthread that processes jobs
from a queue; this thread is the only one that calls Java code.  I
create the JVM in the main thread, and JvAttach/JvDetach in the
created pthread.

I found I can use the basic Rogue Wave synchronization tools (mutexes
and the like) to coordinate the queue, although I had to use the
straight pthreads condition variables for signalling, since the Rogue
Wave escrow objects caused core dumps.

All in all, the scheme was:
  - create JVM in main thread at startup
  - launch single pthread to do all Java calls
  - Rogue Wave threads add jobs (functors) to the queue, then wait for
them to be processed

This works pretty well, so far.

(I go into excruciating detail mostly for the benefit of any other
poor soul who winds up reading this in the archives some day.)

Thanks for your help,

Johann


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]