Suspend or resume method Assignment Help

Assignment Help: >> Threads States - Suspend or resume method

Suspend or resume method:

Since you can't use the suspend ( ) resume ( ), or stop ( ) methods in Java 2 to control a thread, you may be thinking in which no way exists to pause, restart, or terminate a thread. But, fortunately, this is not true. Alternatively, a threads must be designed so in which the run( ) method periodically checks to determine whether that thread  should  suspend, resume, or stop its own  execution. Classically, this is accomplished through establishing a flag variable which denotes the execution state of the thread. As long as this flag is set to "running", the run ( ) method must continue to let the thread execute. The thread must pause if this variable is set to "suspend". If it is set to "stop", the thread must terminate.  Of course, a variety, of ways exists in that to write such code, but the central theme will be the similar for all programs.

The given example describes how the wait ( ) and notify ( ) methods which are inherited from Object can be used to control the execution of a thread; this instance is same to the program in the previous section.  Therefore, the deprecated methods calls have been removed. Consider the operation of this program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd