mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
49 lines
1.6 KiB
Java
49 lines
1.6 KiB
Java
package rpc;
|
||
|
||
import java.util.concurrent.TimeUnit;
|
||
|
||
public class TestRpcClient {
|
||
public static void main(String[] args) throws Exception{
|
||
//Channel channel = new RpcClient().connect("127.0.0.1", 8888);
|
||
|
||
Thread thread1 = new Thread(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
RpcRequest rpcRequest = new RpcRequest();
|
||
rpcRequest.setParam("参数1");
|
||
|
||
try {
|
||
System.out.println("thread1发送请求");
|
||
RpcResponse rpcResponse = RpcUtil.send(rpcRequest, 5, TimeUnit.SECONDS);
|
||
System.out.println("thread1处理结果:" + rpcResponse);
|
||
} catch (Exception e) {
|
||
throw new RuntimeException(e);
|
||
}
|
||
}
|
||
});
|
||
|
||
Thread thread2 = new Thread(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
RpcRequest rpcRequest2 = new RpcRequest();
|
||
rpcRequest2.setParam("参数2");
|
||
|
||
try {
|
||
System.out.println("thread2发送请求");
|
||
RpcResponse rpcResponse = RpcUtil.send(rpcRequest2, 2, TimeUnit.SECONDS);
|
||
System.out.println("thread2处理结果:" + rpcResponse);
|
||
} catch (Exception e) {
|
||
throw new RuntimeException(e);
|
||
}
|
||
}
|
||
});
|
||
|
||
// 休眠一下,等待客户端与服务端进行连接
|
||
Thread.sleep(1000);
|
||
|
||
thread1.start();
|
||
thread2.start();
|
||
|
||
}
|
||
}
|