hallo!! ich habe eine boolische variabel die mit einer while schleife dauernd läuft!! ich muss aber die while schleife als thread schriben aber ich weiß nicht wie ich das tun soll weil schon ein thread vorhanden ist!!
Code:
public void ball(){
g=cv.getGraphics();
while(weiter){
if(x>=cv.getWidth()-10||x<=0){
x1=-x1;
}
if(y>=cv.getHeight()-10||y<=0){
y1=-y1;
}
x=x+x1;
y=y+y1;
g.fillOval(x,y,10,10);
try{
Thread.sleep(10);
}
catch(InterruptedException h){}
g.clearRect(x,y,10,10);
zeichnen();
treffen(x,y);
}
}