On Oct 15, 2007, at 5:10 AM, Eduard de Jong wrote:
Since ALL Java programs are inherently multi-threaded (think Timer,
AWT, SWING), it is an imperative to make any class thread safe.
This I'd say is a little too general. On occasion I think threading
concerns can be pretty much ignored. In the cases you mention and
many others they must be considered.
As your implementation shows, the use of a byte[] instead of a
BigInt as a local variable is more efficient. As a local variable,
that can't be accessed from any other thread, there is no thread-
safety requirement.
This was one reason I thought this a fairly good example. All
manipulations being local clearly can't be a threaded concern. This
somewhat counters threading issues making BigInteger use always
compulsory.
I'd suggest to build the BigInteger version as your reference
implementation! And then replace any internal use of them by a byte
[] to get to your optimization. And wrap the result in an immutable
class.
That is about the approach I'm taking. A prototyping BigInteger
reference version and then a try at a optimized version less reliant
on BigInteger. I'm not quite sure I still see the need for the
immutable wrapper class but I will give it some thought. My own wnaf
class is not meant to be updated after it is instantiated so by
intent it is immutable. I think I do allow access to the
representation byte[] also so I may be in violation of that as well
as the BigInteger version.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden