java - How to stop a process with time constraints -


I think the subject may not be accurate enough, but I really do not know how to describe it in very brief ways. What I want to do ... is as follows: I have some analysis (in Java) running and trying to give a return value, but once a barrier in the whole analysis Is, say 10 seconds

If the analysis returns results within 10, then the result is flame Tie; Otherwise, while reaching Tenth, stop the process and return the dummy value

I am a newbie in this area, any suggestions will be welcome.

You can use to create a job and request results within a particular time (With timeout). If the window is being violated at that time, you will get an exception.

At that point, you can call the method again with the parameter true , block the blockage and cancel the underlying task.

  Object result = dummy; Try {result = futureTask.get (5, TimeOut.SECONDS); } Hold (timeout Exception e) {futureTask.cancel (true); }  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -