[muscle] Re: Assorted java client updates

  • From: Jeremy Friesner <jaf@xxxxxxxxxxxx>
  • To: Lior Okman <lior.okman@xxxxxxxxxxxxxxxxxx>
  • Date: Thu, 28 Dec 2006 10:41:04 -0800

Hi Lior,

Thanks for the patch!  It all looks good, the only thing I changed was the 
reimplementation of Queue.removeAllElements().  I changed it to this:

public void removeAllElements()
   // allow garbage collection
   for (int i=0; i<_elementCount; i++) _queue[internalizeIndex(i)] = null;
   _elementCount = 0;
   _headIndex    = -1;
   _tailIndex    = -1;

The implementation you had was quicker up-front, but it meant that the _queue 
array would have to be re-grown every time after it was cleared, which means 
code with this usage pattern would be inefficient:

Queue q = new Queue()
   for (int i=0; i<10000; i++) q.appendElement(i);

Anyway, your changes will be included in the next muscle release.

Thanks again,

On Thursday 28 December 2006 10:21, Lior Okman wrote:
> Hi Jeremy,
> The attached patch does the following:
> 1. Use a StringBuffer in toString() methods, instead of concatenating
> strings directly.
> 2. Use the faster ByteBuffer operations to fill in arrays, instead of
> looping over the arrays and manually setting the values.
> 3. Use List instead of Vector and HashMap instead of HashTable. This is
> to lose the extra unneeded synchronization point that exists in these
> old and deprecated (as of Java 1.2) classes. Since ByteBuffer assumes at
> least JDK 1.4, no need to use older API.
> 4. Use Iterator instead of Enumeration - same reason as item 3.
> 5. Changed the implementation of Queue.removeAllElements() to a more
> efficient implementation.
> 6. Modified the ThreadPool to use a ThreadGroup and provide thread names
> - this makes the class more profiler friendly.
> Regards,
> Lior

Other related posts: