Package ptolemy.kernel.util.test
Class TestWorkspace2
- java.lang.Object
-
- java.lang.Thread
-
- ptolemy.kernel.util.test.TestWorkspace2
-
- All Implemented Interfaces:
java.lang.Runnable
public class TestWorkspace2 extends java.lang.Thread
This object implements a thread that obtains read permission to a workspace three times sequentially, then calls workspace.wait(obj) on an object and exits. The object "obj" on which the wait method is called is an inner class of TestWorkspace2 and has a thread of its own. This thread gets a write access on the workspace, after the TestWorkspace2 object calls wait(obj) on it. Then it gives up the write access and returns. To use it, create an instance and then call its start() method. To obtain a profile of what it did, call its profile() method. That will return only after the thread completes. NOTE: This is a very primitive test. It does not check very much.- Since:
- Ptolemy II 0.3
- Version:
- $Id$
- Author:
- Mudit Goel, Edward A. Lee
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TestWorkspace2.Notification
Repeatedly calls notifyAll on itself to wake up any threads waiting on it.
-
Field Summary
Fields Modifier and Type Field Description Workspace
_workspace
java.lang.String
profile
-
Constructor Summary
Constructors Constructor Description TestWorkspace2(java.lang.String name, Workspace workspace)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
java.lang.String
profile()
Return a profile which contains the various actions performed by this object.void
run()
Start a thread for an instance of the inner class "Notification", obtain read access on the workspace 3 times, call wait(obj) on the workspace, ask the inner class to get a write access on the workspace and return after relinquishing the read accesses on the workspace.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
_workspace
public Workspace _workspace
-
profile
public java.lang.String profile
-
-
Constructor Detail
-
TestWorkspace2
public TestWorkspace2(java.lang.String name, Workspace workspace)
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
-
run
public void run()
Start a thread for an instance of the inner class "Notification", obtain read access on the workspace 3 times, call wait(obj) on the workspace, ask the inner class to get a write access on the workspace and return after relinquishing the read accesses on the workspace. This method is synchronized both on this class and the inner class- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
profile
public java.lang.String profile()
Return a profile which contains the various actions performed by this object.
-
-