java - Future.get() timeout precision and possible alternatives -


I have some tasks that are limited to the time i have a request for the work server and the result is a response. Time is about 10 milliseconds, after the time has expired, I want to get the results immediately (or within 2-5 milliseconds) or blank so I packed my work in the cell and hoped confidently that the futures with timeout. The gate () will be thrown out of the moment immediately after the expiration. But as I see the futures. With time () can not provide such precision. In my simple test, there are 12 milliseconds in its deviation and it is without high weight. Now I know that it is normal for future Is the behavior. But my work is still there and it will be great to end this more precise time. I've heard of Java Real Time System, but it seems like a very sophisticated tool for me. Is there any easier option for FutureGet () and Java Real Time System?

Did you think record time in the same thread that you use to call with the request Are you? You can throw an exception to the underlying thread and when the future is called, those exceptions will be thrown out there.

I'm not sure that you are familiar with non-blocked-IO, but with this you will not need to stop and continue computing when reading from your stream (i.e. recording while taking operation).

Edit:

java.nio. * Package is a non-blocking IO package available in jse1.7 and later. Here's a basic example to use:



Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -