Note that there are some explanatory texts on larger screens.

plurals
  1. POCancelling an Asynchronous Method Invocation
    primarykey
    data
    text
    <p>I am reading the <a href="http://docs.oracle.com/javaee/6/tutorial/doc/gkkqg.html#gkidb" rel="nofollow">Java EE docs</a> and I have a little problem to understand the purpose of the <code>mayInterruptIfRunning</code> parameter in the method <code>cancel(boolean mayInterruptIfRunning)</code>. I have infered from the docs that the parameter is used to notify the session that the user tried to cancel the invocation and therefore the <code>SessionContext.wasCancelled()</code> method should return true (if the <code>mayInterruptIfRunning</code> was set to true) even if the cancelation failed. If it is right then what is the answer to the following questions:</p> <p>1) When would someone call the cancel method with the <code>mayInterruptIfRunning</code> parameter set to false and what would it mean?</p> <p>2) What is the difference in results coming from the methods <code>SessionContext.wasCancelled()</code> and <code>Future&lt;v&gt;.isCancelled()</code>? Am I right, that the second retuns false if the cancelation failed, whereas the first one returns true even if the cancelation failed provided that one has set the <code>mayInterruptIfRunning</code> to true?</p> <p><strong>Update:</strong></p> <p>Based on the answer I would like to set this question: </p> <p>Assuming that one calls <code>Future.cancel()</code> method with parameter <code>mayInterruptIfRunning</code> false. When is the task cancelled and when not? On what factor does it depend? If the cancellation happens (succeeded) in the above case, will the <code>SessionContext.wasCancelled()</code> return false, whereas the <code>Futute.isCancelled()</code> true? </p>
    singulars
    1. This table or related slice is empty.
    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