<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>FYI thread instances are also re-used in application server environments via managed thread pools. They are considered started when retrieved from the thread pool and run. They are considered to end when returned back to the thread pool. All this happens transparent to the end user. As far as they are concerned they are simply getting new threads. As a result even with pooling in play the thread scope will always be equal to or shorter than an HTTP request.</div><div><br>On Mar 8, 2016, at 9:08 AM, Thomas Andraschko &lt;<a href="mailto:andraschko.thomas@gmail.com">andraschko.thomas@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>+1<br><br></div><div>I also use a own implementation of @ThreadScoped, but currently only via manual start/stop via: ThreadContext.start() or ThreadContext.stop();<br><br></div><div>If provide something, how will it act in a servlet environment? Will it share the same length as RequestScoped?<br></div><div>Threads are reused by Tomcat AFAIR, so actually it would be longer as one request.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-08 14:53 GMT+01:00 Reza Rahman <span dir="ltr">&lt;<a href="mailto:reza_rahman@lycos.com" target="_blank">reza_rahman@lycos.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>In Resin we added it precisely for these reasons and because it is very useful for framework development as opposed to the Java SE thread local API. We started it whenever a thread starts and destroyed it when the thread ends just like thread local. It keeps things simple and consistent.</div><div><div class="h5"><div><br>On Mar 8, 2016, at 8:43 AM, Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Hi guys,<div><br></div><div>following request scope thread and to center the discussion on the thread safety part: do we work on this?</div><div><br></div><div>Background: @RequestScoped is often used as a ThreadLocal instance solution. A lot of SE or Batch implementations rely on it from what I saw as well as async implementations reusing existing business logic with this thread safety constraint.</div><div><br></div><div>Proposal: providing a @ThreadScoped implementation is cheap for CDI and implemenation and would avoid the headache we can have with @RequestScoped. Will also remove the quite dark side of the spec regarding servlet request and request scope since now we would have a more natural solution for all of these situation so @RequestScoped goals wouldn't collide as much.</div><div><br></div><div>Questions:</div><div>- is it automatically started as request scoped is (JMS, @Async, ...)? Alternative could be some configuration in beans.xml (merged accross the app):</div><div><br></div><div>&lt;beans&gt;</div><div>&nbsp; &lt;scopes&gt;</div><div>&nbsp; &nbsp; &lt;thread&gt;</div><div>&nbsp; &nbsp; &nbsp; &lt;active&gt;JMS&lt;/active&gt;</div><div>&nbsp; &nbsp; &nbsp; &lt;active&gt;ASYNCHONOUS&lt;/active&gt;<br></div><div>&nbsp; &nbsp; &lt;/thread&gt;</div><div>&nbsp; &lt;/scopes&gt;</div><div>&lt;/beans&gt;</div><div><br></div><div>- start/stop API (this is typically an API the user should be able to control for its own threads)</div><div>- CDI 2.*0*?</div><div><br></div><div>wdyt?<br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br><span style="font-size:small">Romain Manni-Bucau</span><br><a href="https://twitter.com/rmannibucau" target="_blank">@rmannibucau</a> | &nbsp;<a href="http://rmannibucau.wordpress.com" target="_blank">Blog</a>&nbsp;| <a href="https://github.com/rmannibucau" target="_blank">Github</a>&nbsp;| <a href="https://www.linkedin.com/in/rmannibucau" target="_blank">LinkedIn</a>&nbsp;| <a href="http://www.tomitribe.com" target="_blank">Tomitriber</a></div></div></div></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>cdi-dev mailing list</span><br><span><a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a></span><br><span><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a></span><br><span></span><br><span>Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.</span></div></blockquote></div><br>_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br></blockquote></div><br></div>
</div></blockquote></body></html>