Static Public Member Functions | |
static void | main (String[] args) |
Definition at line 17 of file CounterJvn2.java.
static void counter.CounterJvn2.main | ( | String[] | args | ) | [static] |
Main class. Will create a shared integer object and start counting.
args |
Definition at line 23 of file CounterJvn2.java.
References jvn.JvnException.getMessage(), jvn.JvnServerImpl.jvnLookupObject(), jvn.JvnServerImpl.jvnRegisterObject(), and jvn.JvnObjectImpl.jvnUnLock().
00023 { 00024 try { 00025 // initialize JVN 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 // look up the IRC object in the JVN server 00033 // if not found, create it, and register it in the JVN server 00034 00035 JvnIntegerWrapper jo = (JvnIntegerWrapper)(js.jvnLookupObject("Counter",JvnIntegerWrapper.class)); 00036 if (jo == null) { 00037 jo = new JvnIntegerWrapper(); 00038 // after creation, I have a write lock on the object 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 }