public class TestWaitNotify extends java.lang.Thread
| Modifier and Type | Class and Description |
|---|---|
static class |
TestWaitNotify.WaitNotifyData
This class is visible from outside, it is used from the notifying thread and from this thread,
which waits for data.
|
| Modifier and Type | Method and Description |
|---|---|
void |
run()
This is the thread main-routine complying the Java rules.
|
void |
start()
This routine overrides
Thread.start(), it's a facade. |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yieldpublic void start()
Thread.start(), it's a facade. It calls Thread.start() using
/**@java2c=stackSize(TestThreadLocalData+500). * /
super.start();
It is a facade, containing the stacksize annotation regarded in Java2C-translation.
The produced C-Code is:
start_ThreadJc(ythis, sizeof(TestWaitNotify_Test__TestThreadLocalData_s)+500, _thCxt);
start in class java.lang.Threadjava.lang.Thread#start()}public void run()
TestThreadLocalData, which are accessed by this thread only.
In Java the instances are referenced, but the reference is only known in stack context,
provided to called routines via parameter. In C the instances are allocated in the stack
because a @ java2c=stackInstance. is written thereby. Large-size instances need
an adequate stack size. The Java-code for this code-snippet is:
...* @java2c=stackInstance. * /
TestThreadLocalData threadLocalData = new TestThreadLocalData();
The generated C-code is:
TestThread_Test__TestThreadLocalData_s threadLocalData;
...
init_ObjectJc(&(threadLocalData.base.object), sizeof(threadLocalData), 0);
ctorO_TestThread_Test__TestThreadLocalData(&(threadLocalData.base.object), _thCxt);
The thread contains a while-loop with test of shouldRun and a sleep in the Java-form:
while(shouldRun){
threadLocalData.awaitData();
}//while
In C it is mapped too, but it isn't used yet.
while(ythis->shouldRun) {
awaitData_TestWaitNotify_Test__TestThreadLocalData_F(& (threadLocalData), _thCxt);
}
run in interface java.lang.Runnablerun in class java.lang.Thread