Question 19 Why are Thread methods stop() and suspend() deprecated in Java?
Added by Dan M.
Close
Step 1
The stop() method is deprecated because it is inherently unsafe. When called, it immediately terminates the thread, without giving it a chance to clean up its resources or complete any ongoing tasks. This can lead to inconsistent or corrupted data, as well as Show more…
Show all steps
Your feedback will help us improve your experience
Pritesh Ranjan and 81 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Why is disabling the interrupts in a multicore operating system not considered to be an efficient approach?
Question 2) Thread: ship-island port simulation (40%) You need to design a ship-island port simulation. You are going to have at least 20 ships. Each ship runs as a thread. They all need to get to a port at an island. Island can only have one ship at a time. Question 2 project has two modes "Unsynchronized mode" and "Synchronized mode". The ships may crash under the "Unsynchronized mode" because of race conditions. It shall run safely under the "Synchronized mode". Design YOUR OWN GUI of the project. Two modes are provided ("Unsynchronized mode" and "Synchronized mode"). "Unsynchronized mode" You can build your ship class to extend Thread class or implements Runnable class. When program starts, ships move to the island. If one ship moves to the island, all other ships try to wait until the ship finishes the job (Allows race conditions happen). Ships may crash if there are more than one ship move to island at a time. Your program detects and prints message on the GUI when ships crash. Island icon changes when a ship arrives. "Synchronized mode" You can synchronize your block of code or method. Only one ship moves at a time. (NO race conditions) All ships must finish the jobs safely. Answer the following question as comments in your Ship class (put question and your answer on the first line of your code). Question: "Which object have you chosen for the synchronize? Why?"
Akash M.
What is Life cycle of Java Applet and Hierarchy of Applet
Madhur L.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD