• Post Reply Bookmark Topic Watch Topic
  • New Topic

solve my probelm in creatting thread  RSS feed

 
manish gupta
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in this program there are five method for calling the different web services.
in main method I am calling all these methods but my requirement is I need to call all these method with different thread at same time.
so please let me know how to create different thread and associate each thread with method.

my code is like that :

import java.net.URL;
import java.util.ResourceBundle;
import java.io.IOException;
import java.io.StringReader;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

public class TestAllWebservices extends Thread{

/** Name of the property file */
private static final String PROP_FILE_NAME = "TestProperties";

/** A reference of resource bundle */
private static final ResourceBundle propBundle =
ResourceBundle.getBundle(PROP_FILE_NAME);

public static String callCustomerFastReadBeaWS(){


}
public static String callCustomerFastReadAxisWS(){
// some implemation


}
public static String callCustomerFastReadWmWS(){

// some implemation
}
public static String callNormalReadWmWS(){

// some implemation
}
public static String callForgroundWmWS(){
// some implemation

}
public static String callBackwordWmWS(){
// some implemation

}


public static void main(String[] args) throws Exception {

callCustomerFastReadBeaWS();
callCustomerFastReadAxisWS();
callCustomerFastReadWmWS();
callNormalReadWmWS();
callForgroundWmWS();
callBackwordWmWS();

}

public static String getProperty(String key) throws Exception {


try {
return propBundle.getString(key);
} catch (Exception e) {

throw new Exception(e.getMessage(), e);
}
}
}
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you want to start a new Thread for each service, right? You can make a Runnable that has the code to make the call, run many of them on different threads, join the threads to know when they're all done, and get the results from the Runnable. Read up on Runnable and Thread.start() and Thread.join() for more details.

Now that has much duplication. Adding three more copies of each line would be a real drag. It would be cool to write a method that takes the arguments "one" and "two" or whatever you need to specify each service, creates a runnable and starts a thread.

Did that answer the right question?
[ May 24, 2006: Message edited by: Stan James ]
 
manish gupta
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply,
I will try for that also,Is it possible to create thread with configure no (how many thread want to create) for each service.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!