public void longRunning(long time) {
Toast.makeText(this, "----耗时任务开始执行---", Toast.LENGTH_SHORT).show();
long endTime = System.currentTimeMillis() + time;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
Toast.makeText(this, "----耗时任务执行完成---", Toast.LENGTH_SHORT).show();
}
来源:CSDN
作者:王立平123
链接:https://blog.csdn.net/u013425527/article/details/48466123