Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>1) When would someone called the cancel method with the mayInterruptIfRunning parameter set to false and what would it mean?</p> </blockquote> <p>When you <strong>attempt</strong> to <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#cancel%28boolean%29" rel="nofollow">cancel</a> an asynchronous invocation, you are not sure what the exactly status of the server side method is. The method maybe is still waiting for execution, maybe it was executed or it has already started.</p> <p>The parameter <code>mayInterruptIfRunning</code> is useful for the last case. However, it only makes sense if you have implemented some special logic in the server side, I mean, if you check the status of <code>SessionContext.wasCanceled()</code> method. </p> <p>Just an example:</p> <pre><code>//code that execuete in the asynchronus service while (myCondition) { doSomething(); if (mySessionCtx.wasCancelCalled()) break; } </code></pre> <p>If the method is executing, and you call <code>cancel()</code> with <code>mayInterruptIfRunning = false</code>, the loop won´t finalice until myCondition is false. If the parameter is true, the while loop will be interrupted.</p> <p>Notice that for the <a href="https://java.net/projects/ejb-spec/lists/jsr345-experts/archive/2013-03/message/48" rel="nofollow">moment</a> <code>cancel()</code> doesn´t interrupt the Thread execution.</p> <blockquote> <p>2) What is the difference in results coming from the methods SessionContext.wasCancelled() and Future.isCancelled()?</p> </blockquote> <p>As described above, <code>SessionContext.wasCancelled()</code> is used in the server side whereas that <code>Future&lt;V&gt;.isCancelled()</code> is used in the client side to determine if the task was cancelled.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload