iNTERFACEWARE Products Manual > Installing and Using Chameleon > Language API Documentation > Java Support > Synchronization |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
Chameleon uses an asynchronous model for application development that helps in creating a clean and efficient application. However, this method of development may not be the easiest to use to accomplish simple tasks in a synchronous manner. If you would like to develop a synchronous application with chameleon you'll need to use thread synchronization. Thread synchronization allows your main, synchronous thread to wait for asynchronous events to occur. In Java, synchronization is built into every object with the "notify()" and "wait()" methods and object locks are implemented with the "synchronized" keyword. You need to place the "wait()" call inside a "synchronized" block in order to prevent other threads from modifying the object while your synchronous thread is waiting for an event. Additionally, you may set a timeout for the wait method by calling it with an argument (e.g. "wait(10000)" has a timeout of 10 seconds). |