java - Why does calling a method after a ScheduledExecutorService event only sometimes work? -
given following code, timer scheduledexecutorservice object , runthis runnable object changes appearance of jbutton.
sound.play(); timer.schedule(runthis, 100, timeunit.milliseconds); will call sound.play(), when try
timer.schedule(runthis, 100, timeunit.milliseconds); sound.play(); the method called. have these methods in keylistener keypress method, , sometimes, when press key , repeatedly, sound.play() method not called every time.
why method called , not other times? also, notice usually, when repeat key previous 100 ms over, sound not play.
edit: tried separating contents of keypressed method own method. in other words, did this:
public void keypressed(keyevent e) { pressed(); } public void pressed() { timer.schedule(runthis, 100, timeunit.milliseconds); sound.play(); } i noticed when using separate method, if sound.play() placed before timer.schedule() method, sound skipped every , then. account this?
Comments
Post a Comment