classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java.util.Properties -- make it thread-safe?


From: Artur Biesiadowski
Subject: Re: java.util.Properties -- make it thread-safe?
Date: Fri, 15 Feb 2002 14:50:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8+) Gecko/20020202

Mark Wielaard wrote:

Do newer versions of javadoc really no longer mention wether a method is
synchronized? That would be not good.

This seems obvious for me. In other case people would actually look at javadoc modifiers to see if method is synchronized, instead of checking the description (only place where it can be written).

Compare two methods

public synchronized int hashCode()
{
   int hash = 0;
   for ( int i =0; i < size; i++ )
        hash ^= array[i];
   return hash;
}


public int hashCode()
{
   int hash = 0;
   synchronized(this)
   {
      for ( int i =0; i < size; i++ )
        hash ^= array[i];
   }
   return hash;
}


Do they differ enough to make difference in javadoc ?


This example if of course trivial, but sometimes computations which can be done safely outside synchronization block can be quite expensive. Do you want to take away possibility to optimize it by enforcing people to stick to synchronizing entire method, because it is done such in spec ? Instead of synchronizing only parts which are really needed ?

I was surprised that they EVER documented it in javadoc - but it was probably thinko from early days and only when they wanted to modify something they started to think again.

Artur




reply via email to

[Prev in Thread] Current Thread [Next in Thread]