goxr3plus / goxr3plus/java-stream-player

eventsExecutorService: how does it work?

Open
#49 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
158
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Can you please explain a bit how this works:

https://github.com/goxr3plus/java-stream-player/blob/d32a46a1f7d105a2c5350ae5bd04fdc1edd47baa/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L206-L224

From what I understand, there is a StreamPlayerEventLauncher task which holds information about source, player position, a list of listeners and some other stuff.

The task is submitted to eventsExecutorService.submit(task) and returns a Future.

Then .get() is called on this object. get() blocks until the task is done, i.e., until all listeners have been notified by the call() method of the StreamPlayerEventLauncher.

Since get() is blocking, I wonder why this has to be in a separate thread. What is the lifetime of the thread? It seems to be extremely short, or am I wrong?

Wouldn't the behavior be the same with a simple
new StreamPlayerEventLauncher(this, status, encodedStreamPosition, description, listeners).call();

and no eventsExecutorService at all?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.