//this is my thread:
public class threadMoveRight implements Runnable{
Storeroom sto = new Storeroom();
String url;
Image image1;
boolean flag;
public threadMoveRight(String purl,Image pImage) {
this.url = purl;
this.image1 = pImage;
}
public void run() {
searchData();
flag = true;
}
}
//and after the user press on right he go to this code :
if (sto.doINeedConection){
while (sto.flag==false){
sleep();
}
}
repaint();
//the result:
//the program stay a lot of time in the sleep