//-*-c-*- LockClass { public static void print(PrintWriter out) {{ out.print( "add: public class Cool$Lock {\n"+ " // private fields\n"+ " private java.util.Vector _executing; // Thread\n"+ " private java.util.Vector _locking; // Thread\n"+ " private java.util.Vector _mutex_set; // Lock\n"+ " private boolean _selfex;\n"+ " private static final boolean VERBOSE = ("+"@ false@"+");\n\n"+ " // private methods;\n"+ " private void addMutexElement(Cool$Lock lock) ("+"@\n"+ " this._mutex_set.addElement(lock);\n"+ " @"+")\n"+ " private boolean otherLocking() ("+"@\n"+ " java.util.Enumeration lockers=this._locking.elements();\n"+ " while(lockers.hasMoreElements())\n"+ " if(!lockers.nextElement().equals(Thread.currentThread()))\n"+ " return true;\n"+ " return false;\n"+ " @"+")\n\n"); out.print( " // public methods;\n"+ " public constructor Cool$Lock(boolean selfex_arg, java.util.Vector mutex_arg) ("+"@\n"+ " this._executing=new java.util.Vector();\n"+ " this._locking=new java.util.Vector();\n"+ " this._mutex_set=new java.util.Vector();\n"+ " this._selfex=selfex_arg;\n"+ " if(mutex_arg!=null) {\n"+ " java.util.Enumeration mutex_enum=mutex_arg.elements();\n"+ " while(mutex_enum.hasMoreElements()) {\n"+ " Cool$Lock mutex_elmt=(Cool$Lock)(mutex_enum.nextElement());\n"+ " this._mutex_set.addElement(mutex_elmt);\n"+ " mutex_elmt.addMutexElement(this);\n"+ " }\n"+ " }\n"+ " @"+")\n"+ " public void done() ("+"@\n"+ " this._executing.removeElement(Thread.currentThread());\n"+ " if(this._selfex) this._locking.removeElement(Thread.currentThread());\n"+ " java.util.Enumeration mutex_enum=this._mutex_set.elements();\n"+ " while(mutex_enum.hasMoreElements()) {\n"+ " Cool$Lock mutex_elmt=(Cool$Lock)(mutex_enum.nextElement());\n"+ " mutex_elmt.unlock();\n"+ " }\n"+ " mutex_enum=this._mutex_set.elements();\n"+ " while(mutex_enum.hasMoreElements()) {\n"+ " Cool$Lock mutex_elmt=(Cool$Lock)(mutex_enum.nextElement());\n"+ " mutex_elmt.pushNotify();\n"+ " }\n"+ " this.pushNotify();\n"+ " @"+")\n"); out.print( " public synchronized boolean isEnterable() ("+"@\n"+ " if(otherLocking()) return false;\n\n"+ " this._executing.addElement(Thread.currentThread());\n"+ " if(this._selfex)\n"+ " this._locking.addElement(Thread.currentThread());\n"+ " java.util.Enumeration mutex_enum=this._mutex_set.elements();\n"+ " while(mutex_enum.hasMoreElements())\n"+ " ((Cool$Lock)(mutex_enum.nextElement())).lock();\n"+ " return true;\n\n"+ " @"+")\n\n"+ " public void lock() ("+"@\n"+ " this._locking.addElement(Thread.currentThread());\n"+ " @"+")\n"+ " public void unlock() ("+"@\n"+ " this._locking.removeElement(Thread.currentThread());\n"+ " @"+")\n"+ " public synchronized void pushNotify() ("+"@ notifyAll(); @"+")\n"+ "}\n\n"); out.flush(); }} } XVectorClass { public static void print(PrintWriter out) {{ out.print( "add: public class XVector extends java.util.Vector {\n"+ " public synchronized XVector append(Object object) ("+"@\n"+ " this.addElement(object);\n"+ " return this;\n"+ " @"+")\n"+ "}\n\n"); out.flush(); }} }