Interesting idea.<br><br>I tend to think that more tansparent is better, but, if the overhead weren&#39;t a problem or finding a pattern to apply (Could be a decorator?).<br><br>About your options seems that the second may be more clean, as you comment with Traits.<br>
<br>Well, are only fast thoughts....<br><br><br><div class="gmail_quote">2008/4/24 Guillermo Adrián Molina &lt;<a href="mailto:guille@losmolina.com.ar">guille@losmolina.com.ar</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi!<br>
<br>
I would like to discuss an implementation of thread safe collections (and<br>
streams, and others).<br>
<br>
I can think on three possible approaches, the first one is to convert<br>
every class to be thread safe, the other is to implement new thread safe<br>
classes.<br>
I think that the first approach is interesting because the user wouldn&#39;t<br>
have to care about any thing to be thread safe. We would just use the<br>
class that is guaranteed to be thread safe by the system. But there would<br>
be an overhead imposed by the synchronization mechanism needed by a thread<br>
safe implementation.<br>
The second approach would let you choose between fast thread unsafe<br>
collections, and a slower thread safe collections. But you would have to<br>
choose it yourself. It would not be automatic.<br>
This could be done by subclassing every collection class like this:<br>
<br>
Object<br>
+Collection<br>
&nbsp;+ThreadSafeCollection<br>
&nbsp;+Bag<br>
&nbsp;|+ThreadSafeBag<br>
&nbsp;+Set<br>
 &nbsp;+ThreadSafeSet<br>
<br>
Or doing an entirely new hierarchy like this (with Traits to implement<br>
similar behavior):<br>
<br>
Object<br>
+Collection<br>
|+Bag<br>
|+Set<br>
+ThreadSafeCollection<br>
&nbsp;+ThreadSafeBag<br>
&nbsp;+ThreadSafeSet<br>
<br>
What do you think?<br>
<br>
Cheers<br>
Guille<br>
<br>
<br>
</blockquote></div><br><br clear="all"><br><br>