This example demonstrate wait and notify example. Main thread(ThreadA) will create threadB and will start threadB. After threadB started, it just print that it is started and will go to WAITING state by calling wait(). Meanwhile threadA goes to sleep for 3 seconds and will print that it is awaked and will notify threadB by calling notify(). This will cause to threadB goes to RUNNABLE state. Then it will resume the threadB's execution and will print that it is notified.
Note that when we call wait() and notify(), it should call inside synchronised context. Otherwise it will throw java.lang.IllegalMonitorStateException. We have to pass a lock object to the synchronised block. That object will be blocked during the execution of synchronisation block. In this case I pass the threadB itself as the lock object.
Subscribe to:
Posts (Atom)
How to choose IP address range for resources for AWS virtual private cloud
You will often need to allocate an IP address range when you design the network of an AWS VPC. Since VPC is a small network of resources(E...
-
There are two separate cases for APPM and EMM integration 1. APPM and EMM on a single JVM. ex : EMM standalone pack. 2. APPM and EMM on s...
-
You can create OAuth applications using OAuthAdminService admin service. You can follow the below steps to see how mapping of existing OAu...
-
This guide is for WSO2 BAM 2.5.0 version To change the default admin password open the user-mgt.xml (<BAM_HOME>/repository/conf/) ed...