I will have to implement popups with Java SWT.
Theses popups will pop-up in a 100ms animaiton.
100ms is the border, below of which the user perceive the actions as immediately happened.
The question is: should I use an own thread for this animation?
Do someone know, how the native popups are implemented?
Example: I could call the sleep, between animation steps on the UI thread, or I could extract the sleeping on an extra thread.
for(int i=0; i<height; i+=10){
//change height here
Thread.sleep(10); //makes UI unresposible for 10 ms
}
The question is – is naking the UI unresponsible for such a short time ok, or should it be done on an extra thread?
To answer your question.. I really depends on needs of your application. It’s always really good advice, not to do any long running process in UI thread (always depends on what ‘long’ is).
Anyway, it will not stall your GUI for 10ms, but for 100ms altogether. GUI in SWT is driven by
readAndDispatch()method, so until new call is made, GUI is in frozen state (that’s why you have to usedisplay.syncExec()anddisplayAsyncExec()methods at first place)..