/**
* remoteCall() calls a method remotely by passing in parameters and getting a return Object
*/
- public Object remoteCall(int objectId, String methodSign, Class<?> retType, Class<?> retGenTypeKey,
+ public synchronized Object remoteCall(int objectId, String methodSign, Class<?> retType, Class<?> retGenTypeKey,
Class<?> retGenTypeVal, Class<?>[] paramCls, Object[] paramObj) {
// Send method info
public int callBack() {
- int sum = 0;
+ /*int sum = 0;
for (CallBackInterface cb : cblist) {
sum = sum + cb.printInt();
}
- //sum = cblist.get(1).printInt();
-
- return sum;
+ */
+ final CallBackInterface cb1 = cblist.get(1);
+ final CallBackInterface cb2 = cblist.get(2);
+
+ Thread thread1 = new Thread() {
+ public void run() {
+ try{
+ for(int i = 0; i < 10; i++) {
+ cb1.printInt();
+ Thread.sleep(1000);
+ }
+ } catch (Exception ex){
+ ex.printStackTrace();
+ throw new Error("Error running thread!");
+ }
+ }
+ };
+ thread1.start();
+
+ Thread thread2 = new Thread() {
+ public void run() {
+ try{
+ for(int i = 0; i < 10; i++) {
+ cb2.printInt();
+ Thread.sleep(1000);
+ }
+ } catch (Exception ex){
+ ex.printStackTrace();
+ throw new Error("Error running thread!");
+ }
+ }
+ };
+ thread2.start();
+
+ return 1;
}