真的真的不會做,希望大家幫幫幫幫幫...在線等.............高分相送.....
如果有一個database, 而我想寫一個multi-threading (多线程) 去input 傳送資料入database, 我應該什樣做....
ThoughtClient-----就是interface
ThoughtRO:
ThoughtRMImpl------就是連接database
ThoughtServer------server
我應該從那改和應該什樣做.....我只會做一個單程的server, 大寫可不可以幫幫幫忙.....是不是要用wait()....sleep()....
ThoughtServer class:
mport java.rmi.Naming;
public class ThoughtServer {
//Registered name of the remote object as a constant
public final static String THOUGHT_RO_NAME = "TheThoughtRO";
public ThoughtServer() {
}
public static void main(String[] args) {
//Create main object reference
ThoughtServer theThoughtServerApp = new ThoughtServer();
theThoughtServerApp.go(args);
}
private void go(String[] args) {
//Create a remote object instance
//Note: you must catch the RemoteException thrown
//by the ThoughtROImpl constructor
try {
theThoughtROImpl = new ThoughtROImpl();
//Bind the remote object to the registry
//Note: here we are catching any exceptions thrown
//by the bindRO() method
bindRO();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void bindRO() throws Exception
{
//Register remote object with naming registry
Naming.rebind(THOUGHT_RO_NAME, theThoughtROImpl);
System.out.println("The ThoughtROImpl has been registered");
}
private ThoughtROImpl theThoughtROImpl;
}