class ChildThread extends
Thread
{
public boolean processing = false;
public void run()
{
getResult();
}
public void getResult()
{
connect with webservice and get some data from it. once it is successfully completed,Iam changing the flag value
processing = false;
}
public void post(
string params)
{
after getting parameters from calling method, i am starting this thread
and setting flag value
processing = true;
this. start(); // starting the thread to call run method
}
}
########################
class parent
{
method()
{
new ChildThread().post(String params);
while(processing)
{
print("processing is going on...");
}
doSomethingElse();
}
}
doSomthingElse() gets executed before the childThread run() method is run at all. orelse some times, the childThread start() is not at all calling run() method sothat the parent is going to infinte loop.
I set high priority to childThread . but no use.
As i am using J2ME CLDC 1.1, there is no join() concept or java.util.concurrent library support. If any one knows the solution to how to handle this, kindly post here.