Question 20
Consider the code given below.
class ConferenceRoom { private boolean isRoomAvailable = true; public synchronized void bookRoom(String employeeName) { if (isRoomAvailable) { System.out.println(employeeName + " successfully booked the room."); isRoomAvailable = false; } else { System.out.println(employeeName + " could not book the room."); } }}class Employee implements Runnable { private ConferenceRoom conferenceRoom; private String employeeName;
public Employee(ConferenceRoom cr, String en) { conferenceRoom = cr; employeeName = en; }
public void run() { conferenceRoom.bookRoom(employeeName); }}public class Test{ public static void main(String[] args) { ConferenceRoom room = new ConferenceRoom(); Thread emp1 = new Thread(new Employee(room, "Hema")); Thread emp2 = new Thread(new Employee(room, "Geeta")); Thread emp3 = new Thread(new Employee(room, "Sita")); emp1.start(); emp2.start(); emp3.start(); }}Which of the following options is/are possible result/s of the above code?