[Fwd: Re: Is JAMA thread-safe]
- Subject: [Fwd: Re: Is JAMA thread-safe]
- From: Ron Boisvert <email@example.com>
- Date: Tue, 10 Oct 2006 09:49:30 -0400
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=ISO-8859-1; format=flowed
- User-Agent: Thunderbird 220.127.116.11 (Windows/20060909)
Sender: "Ray A. Conner" <firstname.lastname@example.org>
Subject: Re: Is JAMA thread-safe
Jama isn't thread-safe. My personal opinion is that it shouldn't be,
since the majority of users don't care and this would incur some
overhead, although not much most of the time. Any user who requires
thread-safety can easily enough do that in their own code.
To go into another of my long-winded explanations.... to be thread-safe
an object must behave properly if two (or more) threads of execution
simultaneously use it. The term "thread-safe" is not quite descriptive
enough, but for Matrix objects there's really only three possible ways
for Jama to work:
1) Objects are completely unsynchronized (what it is now).
2) Matrix instances are immutable, which makes synchronization
unnecessary. This isn't feasible because of the storage and time hits
that would take, there would be no set methods, plusEquals, etc.
3) Matrix methods contain sufficient synchronization to keep concurrent
threads from stomping on each other within methods. While this would be
easy to do, I don't think it's very useful. The reason is that it
wouldn't help you if the two threads were performing sequences of
operations, for example:
Thread A Thread B
op#1: x.plusEquals( a ) op#3: x.arrayTimesEquals( y )
op#2: x.plusEquals( b ) op#4: x.arrayTimesEquals( z )
Even if the methods plusEquals() and arrayTimesEquals() were
synchronized so that they couldn't clobber each other, there are
six possible final states for the matrix x depending on how the
operations interleave. Sequences of operations are the rule when
dealing with matrices, not the exception. Only the calling application
can possibly know what sequences of operations must be invoked without
interference, and so the synchronization must be applied at that level.
- Ray A. Conner
Cleve Moler wrote:
> I certainly never considered that issue when I wrote much of the code a
> few years ago. What does it take to make it thread safe?
> -- Cleve Moler
> The MathWorks
> -----Original Message-----
> From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Geri Wagner
> Sent: Monday, October 09, 2006 10:27 AM
> To: Multiple recipients of list
> Subject: Is JAMA thread-safe
> I wonder whether the JAMA implementation is thread-safe.
> I could not find a statetment on the website, but perhaps I have
> overlooked it. Thank you for comments.
Date Index |
Thread Index |
Problems or questions? Contact email@example.com