Hi Peter

I can't give you code samples - I'm a consultant so I'd have to
ask you to pay ;-(

I can go into a bit more detail:

The main issue is the impact on performance of forcing all threads
to synchronize on one global object. If you have a per-thread
circular log queue, each thread can post log messages to the front of the
queue without synchronizing, as the operation of bumping the queue pointer
is atomic (this is a well known feature of circular queues dating back
to the old days of assembler). A global log manager thread can then spin
round the queues, pulling off log objects and printing them. This ensures
that all writes to the log file are serialized appropriately. Even if you
want to do a bit more work and need to synchronize, you are only blocking
the local thread (on its queue), and the log thread - not the other
worker threads so you are not going to impact performace.

Hope this clarifies the situation.

Joel

Peter Michael wrote:
>
> > Hi
> >
> > Both of these solutions are BAD !
> >
> > You should implement a queue which can take multiple threads
> > writing log objects
> > to the queue. You can do this without synchronization using
> > the atomic features
> > of the java language calculations and volatile variables.
>
> Could you please give a code example?
>
> > Then use one thread
> > to pull the log objects of the queue and write them to the file.
> >
> > Locking on a shared object will bottleneck your performance,
> > and JNI is discouraged
> > in EJBs.
> >
> > Joel Crisp, Senior Java Architect, SUN PS Java Center (UK)
> >
> > Srinivasan VS wrote:
> > >
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to