Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncWorker pause failed. #28

Open
easternHong opened this issue May 10, 2016 · 1 comment
Open

AsyncWorker pause failed. #28

easternHong opened this issue May 10, 2016 · 1 comment

Comments

@easternHong
Copy link

//check whether a thread is interruptted or not by this is not a good choice.
Thread#isInterrupted()

i invoke downloader.puaseDownload(int token);
and it finally interrupts the AsyncWorker,but in AsyncWorker this.isInterrupted() is false.
so observer.rebuild(chunk); is invoked .

that is to say ,invoke downloader.puaseDownload(int token); and observer.rebuild(chunk);will be invoked too.
so, the task's state is wrong.

//my solution

volatile boolean interrupt = false;

@Override
public void interrupt() {
      super.interrupt();
      interrupt = true;
}

//update #run
```java
 while (!interrupt &&
       (len = remoteFileIn.read(buffer)) > 0) {
       watchDog.reset();
       chunkFile.write(buffer, 0, len);
       process(len);
 }
if (!interrupt) {
     observer.rebuild(chunk);
}
@BruceYang-yeu
Copy link

it is work for me, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants