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

private Future<Void> future; is never used #51

Open
HelgeStenstrom opened this issue Sep 24, 2019 · 2 comments
Open

private Future<Void> future; is never used #51

HelgeStenstrom opened this issue Sep 24, 2019 · 2 comments
Assignees
Labels

Comments

@HelgeStenstrom
Copy link
Collaborator

This object is never written, but it's read at a few places.
I think the intention might have been to assign it to the result of

For usages of this future, see

/**
* Await for the termination of StreamPlayerExecutorService Thread
*/
private void awaitTermination() {
if (future != null && !future.isDone()) {
try {
// future.get() [Don't use this cause it may hang forever and ever...]
// Wait ~1 second and then cancel the future
final Thread delay = new Thread(() -> {
try {
for (int i = 0; i < 50; i++) {
if (!future.isDone())
Thread.sleep(20);
else
break;
logger.log(Level.INFO, "StreamPlayer Future is not yet done...");
}
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
logger.log(Level.INFO, ex.getMessage(), ex);
}
});
// Start the delay Thread
delay.start();
// Join until delay Thread is finished
delay.join();
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
logger.log(Level.WARNING, ex.getMessage(), ex);
} finally {
// Harmless if task already completed
future.cancel(true); // interrupt if running
}
}
}

@goxr3plus
Copy link
Owner

Now i remember where i used this, i used to return i future from submit event and wait fot it to finish before the next event happens.

So if one Thread called stop and one other pause at the same time it is assured that firstly stop or pause will run and not together, to avoid deadlocks.

Now i remembered :)

@HelgeStenstrom
Copy link
Collaborator Author

But that is not the way it works now, since the future is not returned from submit. It's not even created, as far as I can see. It's null, and line 643 will never be executed.

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

No branches or pull requests

2 participants