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. 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:
>
> Hi
>
> If multiple applications are writing on to the same file, you might need to
> implement the writing using JNI (C does provided for opening a file in
> mutually exclusive  mode). I dont
> think Java allows opening a file in mutually exclusive mode.
>
> If multiple threads of the same application are writing to the same file,
> you might consider getting locks on a shared object.
>
> Hope this helps
> srini
> ----- Original Message -----
> From: Sanjay Nambiar <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, November 20, 1999 4:52 AM
> Subject: Java implementation Query:Urgent
>
> > Hi All,
> > Sorry to post this mail on this mailing list.But if some one could provide
> a
> > solution.....
> > We have "probably" a preliminary query.
> > In our application we would like to write to one log file by multiple
> > processes.The problem we are facing is as follows:
> > We have to implement one log class which would be static and a method of
> > that class would be called by the respective
> > applications.
> >
> > During writing to the file, the messages are being Garbled as shown below.
> > Error Num Insert query is as follows:"....."
> > Where the string "Error Num" actually is a complete string "Error Number
> is
> > :100 ISAM Query" .
> >
> > This is because multiple applications are trying to write to the file at
> the
> > same time.
> > We have implemented RandomAccessFile.Method is
> RandomAccessFile.WriteBytes()
> > We request for a solution in terms of brief pointers or a detailed
> solution.
> >
> > Regards,
> > SANJAY Nambiar
> >
> >
> ===========================================================================
> > 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".

===========================================================================
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