I have a program based on MVC which gets data from internet and start to parsing it and of course in networking programs we need to have threads.
I have a class for reading data from internet such below :
public class WebReader extends Thread
{
private String result="";
public String getResult()
{
return result;
}
public void setResult(String t)
{
result = t;
}
public WebReader(get args here)
{
//initializing
}
public void getData()
{
//call the big getData(args);
}
public void getData(Sargs)
{
//magics happens here
}
@Override
public void run()
{
//call getData()
}
}
and for using this class inside my model I've been using below code :
//inside a function
WebReader wr = new WebReader(args);
wr.start();
wr.join();
String s = wr.getResult();
this.parseData(s);
I know by using join() I'm join the thread to the current thread and by doing this my GUI will stuck till complete result come from network. but I want to be sure that WebReader class has read the data first and then carry on what should I do for that?