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

ExecutorService is not shut down #1

Open
IARI opened this issue Mar 9, 2019 · 6 comments
Open

ExecutorService is not shut down #1

IARI opened this issue Mar 9, 2019 · 6 comments

Comments

@IARI
Copy link

IARI commented Mar 9, 2019

First of all thanks for the work on this project - works wonderfully.

I used it in a JavaFX application and noticed, that after calling Platform.exit(), the process was still running.
It seems like the StreamPlayer class uses Java8 ExecutorService, but never shuts it down.

How about adding a public method to shut down the ExecutorServices ?

@goxr3plus
Copy link
Owner

goxr3plus commented Mar 9, 2019

Yess i should add more examples.
You can call

player. stop() where player is your instance. Before you exit the application :)

You can also see the code of XR3Player which i have implemented everything and it is a JavaFX Media Player.

Keep me notified.

@IARI
Copy link
Author

IARI commented Mar 9, 2019

Hi and thanks for the quick reply :)

calling stop alone doesn't do it for me: the process keeps running.
Currently I'm getting both private executors from the class via reflection like this (sorry, it's kotlin code)

    init {
        appCtl.exitHandler.add {
            log.info("Exit handler")
            stop()
            getExecutorService("streamPlayerExecutorService").shutdownNow()
            getExecutorService("eventsExecutorService").shutdownNow()
        }
    }

    private fun getExecutorService(fieldname: String) =
        StreamPlayer::class.java.getDeclaredField(fieldname).run {
            isAccessible = true
            get(streamPlayer) as ExecutorService
        }

@goxr3plus
Copy link
Owner

player. stop() doesn't work really? Like i am using it in my own app. How is that possible. Ah yes yes. You can exit your application with System.exit(-1) or 0

@goxr3plus
Copy link
Owner

Executors shutdown isn't promising to terminate just the second you call it.

@TonalidadeHidrica
Copy link
Contributor

Maybe some wants the thread to be automatically halted right after all other threads finished. If the two (is it correct?) threads were daemon it would be helpful, so maybe adding daemon-thread option is one way.

@goxr3plus
Copy link
Owner

Yes that's a good idea 💡. Hm i am thinking how to code it m

This was referenced Sep 3, 2019
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

3 participants