[concurrency-interest] ConcurrentReaderHashMap kudos!

Alexey N. Solofnenko A.Solofnenko@mdl.com
Sat, 04 Dec 2004 22:44:20 -0800


I do not think it is a good idea to call a virtual (even abstract) 
method from a constructor. At least in C++ it was a deadly sin.

- Alexey.

Elias Ross wrote:

>public abstract SyncMapOperation {
>  public SyncMapOperation(SyncMap sm) {
>    try {
>      sm.readerSync().acquire();
>      for (Iterator i = ssm.entryMap().iterator(); i.hasNext(); )
>         operate((Map.Entry)i.next());
>    } finally {
>      sm.readerSync().release();
>    }
>  }
>  public abstract void operate(Map.Entry me);
>}
>
>and then, if you want to print the list, for example, you would do this:
>
>new SyncOperation(ssm) {
>  public void operate(Map.Entry me) {
>    System.out.println(me);
>  }
>};
>
>  
>