以下は私がthrift
サーバーを実装した方法ですが、呼び出し後にメインのtheradに戻りませんserve()
。
public class ThriftServerRunner implements Runnable {
private int thriftServerPort;
public ThriftServerRunner(int thriftServerPort, LogWriter logWriter) {
this.thriftServerPort = thriftServerPort;
}
@Override
public void run() {
try {
SetupThriftServer();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void SetupThriftServer() throws Exception {
try {
TServerSocket serverTransport = new TServerSocket(this.thriftServerPort);
ThriftService.Processor<ThriftService.Iface> processor = new ThriftService.Processor(new ThriftServiceImpl());
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
server.serve();
} catch (TTransportException e) {
e.printStackTrace();
}
}
}