我正在尝试实现一个音乐播放器。我写了一个从 Thread 扩展的类,并重写了它的 Start()-Method 来播放一首随机歌曲。
播放歌曲有效,但我想将该线程发送到后台,这不起作用:
File file = new File("song.mp3");
PlayEngine plengine = new PlayEngine(); //This class extends from Thread
plengine.Play(file); //This just sets the file to play in a variable
plengine.Start(); //And this finally plays the file itself
System.out.println("Next task:"); // I don't get to this point. Only when the song has finished.
正如您在上面的代码中看到的,我想在启动线程后立即转到打印行。