Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: immutable BigInteger




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.


Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



_______________________________________________
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

This email sent to email@hidden
References: 
 >Re: immutable BigInteger (From: Michael Hall <email@hidden>)
 >Re: immutable BigInteger (From: Eduard de Jong <email@hidden>)
 >Re: immutable BigInteger (From: Michael Hall <email@hidden>)
 >Re: immutable BigInteger (From: Eduard de Jong <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.