你好,我想知道在非UI线程中使用Thread.sleep(x)的while循环对性能有多大影响,它会占用CPU周期吗?例如:
boolean[] flag = {false};
//New thread to show some repeated animation
new Thread(new Runnnable{ run() {
while(true){
someImageView.animate()....setListener(.. onComplete(){ flag[0] = true; } ..).start();
}
}).start()
//Wait for flag to be true to carry on in this thread
while(!flag[0]){
Thread.sleep(100);
}