开发者

Thread sleep will it stop the audio [closed]

开发者 https://www.devze.com 2023-03-11 20:26 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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

关注公众号