-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hi folks,
I tried to use two threads to make different contract calls. Sometimes their responses may interfere with each other.
For this test, I defined the following class.
private class ContractCallThread extends Thread {
public ContractCallThread(ContractCall contract, String method, Type<?>... args) {
this.contract = contract;
this.method = method;
this.args = args;
}
public void run() {
this.result = this.contract.call(this.method, this.args).sendAndGet();
}
public String result() {
return this.result;
}
private ContractCall contract = null;
private String method = null;
private Type<?>[] args = null;
private String result = null;
}
The test code is as follows.
while (true) {
ContractCallThread getOutputsThread1 = new ContractCallThread(<contract_name>, <method_name>, <args_1>);
ContractCallThread getOutputsThread2 = new ContractCallThread(<contract_name>, <method_name>, <args_2>);
getOutputsThread1.start();
getOutputsThread2.start();
getOutputsThread1.join();
String result1 = getOutputsThread1.result();
<check_result1>
getOutputsThread2.join();
}
You'll soon get a result1 corresponding to args_2.
Could you please take a look? Thanks!
-linyufly
Metadata
Metadata
Assignees
Labels
No labels