Let's say I am writing a small game. With a lot of buttons in it. In the game, when the user click two adjacent buttons, if they exchange and if some criteria meets, I'll change something. If not, the layout get back to original. Now how to have the temporary state displayed for one second? The temporary state refers to after they exchange..
【在 n*****k 的大作中提到】 : : A Timer??? You'd better elaborate your question a little.
KG
4 楼
Although the scenario is still not clear, I would guess that you put Thread.currentThread.wait(1000) inside an event dispatch thread. That would just put your event dispatch thread on hold for a sec, during which time period UI won't be updated. Using a Timer might work...
【在 g*****g 的大作中提到】 : Let's say I am writing a small game. With a lot of : buttons in it. : In the game, when the user click two adjacent buttons, : if they exchange and if some criteria meets, I'll change : something. If not, the layout get back to original. : Now how to have the temporary state displayed for one : second? The temporary state refers to after they exchange..
g*g
5 楼
That's the scenario, can you give some details on how to update UI when the working thread is suspended?
【在 KG 的大作中提到】 : Although the scenario is still not clear, I would guess that you put : Thread.currentThread.wait(1000) inside an event dispatch thread. That would : just put your event dispatch thread on hold for a sec, during which time : period UI won't be updated. Using a Timer might work...
m*t
6 楼
I think his point is *not* to suspend any thread. Instead, use a timer to triger the second update.
【在 g*****g 的大作中提到】 : That's the scenario, can you give some details on : how to update UI when the working thread is suspended?