Question: 1/ What are the ways you can make an instance of your class be able to start a thread? In other words, what can you

1/ What are the ways you can make an instance of your class be able to start a thread? In other words, what can you add to your class definition to mark it as being capable to start a thread?

Multiple answers

  1. Just implement run() method without changing the class header
  2. Implement Synchronized interface
  3. Extend Thread class
  4. Implement Thread interface
  5. Extend MainThread class
  6. Implement Runnable interface

2/ What are some of the ways to achieve object locks by threads in Java?

multiple answers

  1. Static synchronization
  2. Concurrent blocks
  3. Synchronized method
  4. Synchronized block
  5. Adding transient keyword
  6. Changing thread priorities for each thread to ensure they are scheduled for execution sequentially
  7. Efficient thread communication
  8. Concurrent methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!