<div dir="ltr">Agreed, this is why Java serialization works with final fields :). I meant something else, which I now understand that I was wrong. For some unknown reason to me, I thought that the HTTP request message, for example, does not have its own copy of ChannelBuffer.<div>

<br></div><div>-shay.banon<br><br><div class="gmail_quote">On Wed, Mar 3, 2010 at 11:50 AM, &quot;Trustin Lee (ÀÌÈñ½Â)&quot; <span dir="ltr">&lt;<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Shay,<br>
<br>
I think it is safe even if you do not copy the content of the array if<br>
the happens-before condition meets. &nbsp;For example, this is safe:<br>
<br>
Thread A:<br>
<br>
 &nbsp; &nbsp;sharedByteArray[0] = 1;<br>
 &nbsp; &nbsp;taskQueue.offer(something);<br>
<br>
Thread B:<br>
<br>
 &nbsp; &nbsp;taskQueue.poll(); // get something<br>
 &nbsp; &nbsp;assert sharedByteArray[0] == 1;<br>
<br>
For more information, read this article:<br>
<br>
 &nbsp; &nbsp;<a href="http://www.ibm.com/developerworks/library/j-jtp03304/" target="_blank">http://www.ibm.com/developerworks/library/j-jtp03304/</a><br>
<br>
HTH,<br>
Trustin<br>
<div class="im"><br>
Shay Banon wrote:<br>
&gt; Just to clarify this (and correct me if I am wrong here Trustin), if<br>
&gt; then, you are going to use that byte array in another thread (for<br>
&gt; example, using the execution handler), then you have to copy it over.<br>
&gt; For example, in your http request message handler which then delegates<br>
&gt; the handling of the Http request to another thread.<br>
&gt;<br>
&gt; -shay.banon<br>
&gt;<br>
&gt; On Wed, Mar 3, 2010 at 7:56 AM, &quot;Trustin Lee (ÀÌÈñ½Â)&quot;<br>
</div><div class="im">&gt; &lt;<a href="mailto:trustin@gmail.com">trustin@gmail.com</a> &lt;mailto:<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; Adam,<br>
&gt;<br>
&gt; &nbsp; &nbsp; Netty 3.2 adds array() and hasArray() to ChannelBuffer.<br>
&gt;<br>
&gt; &nbsp; &nbsp; In 3.1, you can call toByteBuffer() which will not involve memory copy<br>
&gt; &nbsp; &nbsp; if possible.<br>
&gt;<br>
&gt; &nbsp; &nbsp; HTH,<br>
&gt; &nbsp; &nbsp; Trustin<br>
&gt;<br>
&gt; &nbsp; &nbsp; Adam Durana wrote:<br>
&gt; &nbsp; &nbsp; &gt; Hi,<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; I&#39;m looking for the most efficient way to get a ChannelBuffer&#39;s data<br>
&gt; &nbsp; &nbsp; &gt; in the form of a byte array. &nbsp;The byte array will be only read from<br>
&gt; &nbsp; &nbsp; &gt; and not modified. &nbsp;Is the best way to use a ChannelBuffer&#39;s readBytes<br>
&gt; &nbsp; &nbsp; &gt; method to copy the data into an array? &nbsp;Or is there a way that doesn&#39;t<br>
&gt; &nbsp; &nbsp; &gt; involve copying given that I&#39;m not going to be modifying the array?<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; Thanks,<br>
&gt; &nbsp; &nbsp; &gt; Adam<br>
&gt; &nbsp; &nbsp; &gt; _______________________________________________<br>
&gt; &nbsp; &nbsp; &gt; netty-users mailing list<br>
</div>&gt; &nbsp; &nbsp; &gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>&gt;<br>
<div class="im">&gt; &nbsp; &nbsp; &gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
&gt;<br>
&gt; &nbsp; &nbsp; --<br>
&gt; &nbsp; &nbsp; what we call human nature in actuality is human habit<br>
&gt; &nbsp; &nbsp; <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; _______________________________________________<br>
&gt; &nbsp; &nbsp; netty-users mailing list<br>
</div>&gt; &nbsp; &nbsp; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>&gt;<br>
<div class="im">&gt; &nbsp; &nbsp; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">&gt;<br>
&gt; _______________________________________________<br>
&gt; netty-users mailing list<br>
&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
--<br>
what we call human nature in actuality is human habit<br>
<a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
<br>
<br>
</div></div><br>_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></blockquote></div><br></div></div>