On Mon, 21 Mar 2022 13:19:14 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> How about setting the status to ABORTED only if it is Interrupted.....?
>> 
>>>             try {
>>>                 mTracker.waitForID(id, 0);
>>>             } catch (InterruptedException e) {
>>>                 bIsInterrupted = true;
>>>             }
>>>             if (bIsInterrupted == true)
>>>             {
>>>                 loadStatus = MediaTracker.ABORTED;
>>>             }
>>>             else
>>>             {
>>>                 loadStatus = mTracker.statusID(id, false);
>>>             }
>
> That's a good point. However, you have get the status from `MediaTracker` 
> first: the image could finish loading before the thread was interrupted.
> 
> 
>         try {
>             mTracker.waitForID(id, 0);
>         } catch (InterruptedException e) {
>             interrupted = true;
>         }
> 
>         loadStatus = mTracker.statusID(id, false);
>         mTracker.removeImage(image, id);
>         if (interrupted && (loadStatus & MediaTracker.LOADING != 0)) {
>             loadStatus = MediaTracker.ABORTED;
>         }
> 
> 
> On the other hand, if the thread isn't interrupted, `waitForID` returns only 
> after the image moves into its final state: `LOADED`, `ABORTED`, or 
> `ERRORED`; if its status is still `LOADING`, the thread is interrupted.
> 
> Therefore my original suggestion is still correct: the status is amended only 
> when the thread is interrupted. Yet the intention of the code seems clearer 
> with the additional `interrupted` flag. At the same time, I'm still inclined 
> towards the shorter version without the flag.

Yeah, I was also thinking about the load COMPLETE case...... sure then will 
update the same......

-------------

PR: https://git.openjdk.java.net/jdk/pull/7754

Reply via email to