开发者

Handling java.util.concurrent.Future with null result

If I submit task, and futureTask.get() returns null, I would like to process what I sent in the Callable object another way. When debugging, I can see that my Future has a private final member called "sync". "sync" contains my callable, which has the original data that I sent in the Callable. Unfortunately, I can't get to it.

In pseudocode...

Callable callable = new Callable(myData);

Future future = executor.submit(callable);

if (future.get() == null)
{
     //what I would like to have if the "sync" member was available..
      String alreadySubmittedData = future.sync.callable.myData;
 }

It seems like there should be a way to 开发者_如何学Cdo this? Thanks.


Callable and Future are just interfaces anyway, so I guess you have to keep that info around yourself (e.g. associating futures to callables in a map).


Why you can't get myData from your variable callable?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜