org.vishia.java2C.test
Class TestWaitNotify.WaitNotifyData

java.lang.Object
  extended by org.vishia.java2C.test.TestWaitNotify.WaitNotifyData
Enclosing class:
TestWaitNotify

public static final class TestWaitNotify.WaitNotifyData
extends java.lang.Object

This class is visible from outside, it is used from the notifying thread and from this thread, which waits for data.


Field Summary
(package private)  int ctNewData
          Sequence counter to detect a notify.
(package private)  int x
          A value which is supplied with notify.
 
Constructor Summary
TestWaitNotify.WaitNotifyData()
           
 
Method Summary
 void notify(int value)
          Notify routine, it may be called from outside.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

int x
A value which is supplied with notify.


ctNewData

int ctNewData
Sequence counter to detect a notify. It is incremented on any notify().

Constructor Detail

TestWaitNotify.WaitNotifyData

public TestWaitNotify.WaitNotifyData()
Method Detail

notify

public void notify(int value)
Notify routine, it may be called from outside. New data are stored than. The notify()-call have to be placed in a synchronized- (mutex-)-block. Elsewhere in Java an exception is thrown. It is necessary to do so. That synchronized-block should be used to set the data, which are supplied with the notify action. Than the data and the notify-call are mutual exclusive handled. The Java-code is:
      synchronized(this){
        x = value;
        ctNewData +=1;
        notify();
      }  
 
The value is stored. The sequence counter is incremented to advertise the notify. Than notify is called. All this operations are done under mutex in the synchronized-block. The translated C-code is:
    synchronized_ObjectJc(& ((* (ythis)).base.object)); {
      ythis->x = value;
      ythis->ctNewData += 1;
      notify_ObjectJc(& ((* (ythis)).base.object), _thCxt);
    } endSynchronized_ObjectJc(& ((* (ythis)).base.object));
 

Parameters:
value - The value supplied with notify.