真的真的不會做,希望大家幫幫幫幫幫...在線等.............高分相送.....

kaiyim 2004-05-11 07:12:33
如果有一個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;
}
...全文
35 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
raimundo 2004-05-12
  • 打赏
  • 举报
回复
可以参考Rickard Oberg的《Mastering RMI》中Chapter 7,有一个简单的应用mutil-thread写的RMI server的例子
kaiyim 2004-05-12
  • 打赏
  • 举报
回复
help.......who can help me
kaiyim 2004-05-11
  • 打赏
  • 举报
回复
up
kaiyim 2004-05-11
  • 打赏
  • 举报
回复
可不可給一些意見或例子給我
michael135791 2004-05-11
  • 打赏
  • 举报
回复
其实这个程序并不是很复杂,有一点你不太清楚,至于wait() and sleep(),You can think about these two methods.

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧