我有代码:
public void repaint()
{
int i;
for(i=0; i<4; i++)
{
Thread thread = new Thread()
{
@Override
public void run()
{
System.out.println("BEFORE PAINT");
paint(); //my own function for painting on Canvas
}
};
thread.setPriority(MAX_PRIORITY);
thread.start();
while(thread.isAlive())
{
sleep(1000);
System.out.println("PAINTING");
}
}
}
我想在每个循环周期中重新绘制画布。
控制台输出:
之前的油漆
PAINTING
之前的油漆
PAINTING
之前的油漆
PAINTING
之前的油漆
PAINTING
但是在这种情况下是从函数repaint()返回后画布重绘!!!我做错了什么?
感谢您的回答!!