开发者

Thread sleep will it stop the audio [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the开发者_Go百科 help center. Closed 10 years ago.

In my program: I play an audio... I want that when it ends, then the next command be executed..

if I use Thread.sleap, will the sound keep playing

is there an alternative to Thread.sleep?

Thread.sleep(5000); 
System.out.println("Song is over");


If you are playing the audio on the current thread, Thread.sleep(5000) will stop the audio. Note that sleep() is a static method and you call it on the current thread. So if your audio is playing on another Thread t, then calling t.sleep(5000) from another thread will not stop the t thread. Instead it will sleep the current thread from which you are making the call. Hope this helps.

Not sure what you mean by alternative to Thread.sleep(). Thread.yield()?


Have you tried anything??

Unless you are playing the audio in a separate thread, the next command should be executed once that the audio clip is played. The code snippet you gave us is pretty limited for us to provide you with a complete answer that suits your case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜