I am newbie to j2me.
I am using threading concepts to connect with webservices.
I have two classes - Sync (which acts as main ) and TestConnectionThread(which is used to connect webservice and for checking whether testConnection is succeed)
TestConnectionThread contains post() method which accepts the webservice url and starts the
thread(calls run() method)
What I want is - child thread(i.eTestConnectionThread) has to complete first before Sync has to complete. I am not able to use childThread.join() in Sync class because I am using j2me cldc 1.1. So, I tried with, Thread.sleep(), Thread.yield in sync class. but of no use.
Every time, the child Thread is creating successfully and near the ht.call method, it is waiting for some time(because it has to hit webservices and get back the response). So, in this mean while, the control is giving back to the parent( i.e Sync). Once it happend, childThread is not getting the control until the parent (Sync) is over. (Even though I set high priority to childThread or increasing the time in while loop). So, because of that .. even though the testConnection is succeeded, in Sync it is showing isConnection is failed.
Please let me know how can i achieve - Sync has to wait until TestConnectionThread connection is succeded.
(i.e 'TestConnection Thread - GetResult()- got response from webservice:true' has to appear before 'Sync - checkTestConnection() - isConnection value =false' sothat isConnection value will print true)
Here are the programs and console output for tracing
#############################
output
##########################
Sync - checkTestConnection()
current thread name & priority:Thread-4-5
TestConnection Thread - posted parameters -
urlhttp://172.16.25.149/fpstcservicebb/stc.asmx
In URL
http://172.16.25.149/fpstcservicebb/stc.asmx
Connecting To Server...
TestConnectionThread - run()
TestConnectionThread - run() - thread name and priority :Thread-7-10
TestConnectionThread - run()-inside thread running
TestConnection Thread - GetResult()
soapActionhttp://tempuri.org/TestConnection
In URL
http://172.16.25.149/fpstcservicebb/stc.asmx
TestConnection Thread - GetResult() - before ht.call
Connecting To Server....
Connecting To Server.....
Connecting To Server......
Connecting To Server.......
Connecting To Server........
Connecting To Server.........
Connecting To Server..........
Connecting To Server...........
Connecting To Server............
Sync-checkTestConnection()- inside time out
<<<<<<<<<<< thread killed <<<<<<<<<<<<<<<<
Sync-checkTestConnection()-while is over
Sync-checkTestConnection()- inside else block>>>>>>>>>>>>>>>>>>>>>>
Sync - checkTestConnection() - finally value is set to : false
Sync - checkTestConnection() - isConnection value =false
TestConnection Thread - GetResult() - after ht.call
TestConnection Thread - GetResult()- got response from webservice:true
TestConnection Thread - GetResult() - set constants url as
http://172.16.25.149/fpstcservicebb/stc.asmx
TestConnection Thread - GetResult() - sending value :false