Meaning of task.get

Asked 1 years ago, Updated 1 years ago, 119 views

    try {
        task.get(1000, TimeUnit.MILLISECONDS);
    } } catch (ExecutionException e) {
        e.printStackTrace();
    } } catch (InterruptedException e) {
        e.printStackTrace();
    } } catch (TimeoutException e) {
        e.printStackTrace();
    }

I wonder what this code means. in the async task I think it goes in after executing the task, can I know the meaning?

android java android-asynctask

2022-09-21 17:00

1 Answers

If you raise the sauce like this, I can't tell exactly what type task is, so please fill it out so that you can see the package.

I think it's android.os.AsyncTask#get(long timeout, TimeUnit) in context.

task.get(1000, TimeUnit.MILLISECONDS);

Here, get means to return the execution result of task, but if necessary, wait until task is finished. If it does not exit after 1000 milliseconds, the TimeoutException exception occurs.


2022-09-21 17:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.