In my java gui program, I have a button, of which upon clicking, will create a new thread that plays a song in the background. Had I not created a new thread, and just played it in the actionListener, the song would freeze up the rest of the gui to be unusable until it finished.
However, I would like a means for the user to stop the song.. which in code I would take to mean 'terminate the thread'. I've tried some online answers like the deprecated .stop() .interrupt() methods, but they don't seem to work. I think this has something to do with the fact that the thread that plays the song is in Thread.sleep() for the duration of the song.. any way to terminate a sleeping thread? -Thanks