<div dir="ltr">(Resurrecting this thread. Happy New Year!)<div><br></div><div>Another (related) case I had a question about.</div><div><br></div><div>Suppose I have the standard SeContainer "block" like this:</div><div><br></div><div>try (final SeContainer container = initializer.initialize()) {</div><div> // stuff goes here</div><div>}</div><div><br></div><div>Inside that block, may I start threads and have them do things with the container variable? It sounds like strictly speaking no, I may not—i.e. that the specification, since it says nothing one way or the other about threading, therefore implies that only one thread may, say, iterate over the container (either using its iterator() or stream() methods).</div><div><br></div><div>On the other hand, I see no restriction in the specification on the creation of threads from, say, a managed bean, which means it is always possible that at any point an Instance object may be used by many threads. Or, further, since events may be fired asynchronously, then it would <i>seem</i> to follow that iteration over an Instance must be thread safe.</div><div><br></div><div>Should the specification include language related to concurrency in these matters and others?</div><div><br></div><div>Best,</div><div>Laird</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 8, 2016 at 1:37 AM Martin Kouba <<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I agree with John, it's not guaranteed. However, the original intention<br class="gmail_msg">
(based on Weld SE impl) was:<br class="gmail_msg">
<br class="gmail_msg">
* SeContainerInitializer is not thread-safe and should not be shared<br class="gmail_msg">
between threads<br class="gmail_msg">
* it should be safe to call SeContainer.close() from any thread<br class="gmail_msg">
<br class="gmail_msg">
Martin<br class="gmail_msg">
<br class="gmail_msg">
Dne 7.12.2016 v 22:01 John Ament napsal(a):<br class="gmail_msg">
> I would say that this is not guaranteed.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> ------------------------------------------------------------------------<br class="gmail_msg">
> *From:* <a href="mailto:cdi-dev-bounces@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev-bounces@lists.jboss.org</a><br class="gmail_msg">
> <<a href="mailto:cdi-dev-bounces@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev-bounces@lists.jboss.org</a>> on behalf of Laird Nelson<br class="gmail_msg">
> <<a href="mailto:ljnelson@gmail.com" class="gmail_msg" target="_blank">ljnelson@gmail.com</a>><br class="gmail_msg">
> *Sent:* Wednesday, December 7, 2016 3:56 PM<br class="gmail_msg">
> *To:* <a href="mailto:cdi-dev@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev@lists.jboss.org</a><br class="gmail_msg">
> *Subject:* [cdi-dev] Thread safety of SeContainer and<br class="gmail_msg">
> SeContainerInitializer<br class="gmail_msg">
><br class="gmail_msg">
> Are SeContainer and SeContainerInitializer safe for concurrent use by<br class="gmail_msg">
> multiple threads? The string "concurren" shows up only four times in<br class="gmail_msg">
> the 2.0 specification but not in this context.<br class="gmail_msg">
><br class="gmail_msg">
> I'm most interested in whether it is guaranteed that one thread may call<br class="gmail_msg">
> SeContainer::initialize and another may call SeContainer::close.<br class="gmail_msg">
><br class="gmail_msg">
> I'm assuming that this is /not/ guaranteed.<br class="gmail_msg">
><br class="gmail_msg">
> Best,<br class="gmail_msg">
> Laird<br class="gmail_msg">
> ------------------------------------------------------------------------<br class="gmail_msg">
> NOTICE: This e-mail message and any attachments may contain<br class="gmail_msg">
> confidential, proprietary, and/or privileged information which should be<br class="gmail_msg">
> treated accordingly. If you are not the intended recipient, please<br class="gmail_msg">
> notify the sender immediately by return e-mail, delete this message, and<br class="gmail_msg">
> destroy all physical and electronic copies. Thank you.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> cdi-dev mailing list<br class="gmail_msg">
> <a href="mailto:cdi-dev@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev@lists.jboss.org</a><br class="gmail_msg">
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br class="gmail_msg">
><br class="gmail_msg">
> 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" class="gmail_msg" 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 class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Martin Kouba<br class="gmail_msg">
Software Engineer<br class="gmail_msg">
Red Hat, Czech Republic<br class="gmail_msg">
</blockquote></div></div>