00001
00008 package counter;
00009
00010 import jvn.JvnException;
00011 import jvn.JvnServerImpl;
00012
00017 public class CounterJvn2 {
00018
00023 public static void main(String[] args) {
00024 try {
00025
00026 JvnServerImpl js = JvnServerImpl.jvnGetServer();
00027
00028 if (js == null) {
00029 System.out.println("Counter stress test problem : cannot create server!");
00030 }
00031 else {
00032
00033
00034
00035 JvnIntegerWrapper jo = (JvnIntegerWrapper)(js.jvnLookupObject("Counter",JvnIntegerWrapper.class));
00036 if (jo == null) {
00037 jo = new JvnIntegerWrapper();
00038
00039 jo.jvnUnLock();
00040 js.jvnRegisterObject("Counter", jo);
00041 }
00042 while(true) {
00043 try {
00044 int number = jo.read();
00045 System.out.println("Current number is "+number+", next number shall be "+(++number));
00046 jo.write(number);
00047 } catch (JvnException je) {
00048 System.out.println("Counter stress test problem : " + je.getMessage());
00049 }
00050 }
00051 }
00052 } catch (JvnException je) {
00053 System.out.println("Counter stress test problem : " + je.getMessage());
00054 }
00055 }
00056 }