//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

??????????

What is your question/problem?

the program stay in the loop and i want that the program will calc the data and go to the internet but it stock....

hint: which flag are you setting and which flag are you checking?