Java concurrency without using Thread or ExecutorService

There is this task that was given to me to do and I have tried all my best but couldn’t be able to achieve it. The task is to write a Java Program that will produce a pancake and at the same time users will be picked at random to eat the produced pancakes. The two things must be done concurrently, meaning that as the pancake is being produced, users will check if there is any available pancake produced and then eat it. Each user is expected to eat a maximum of 5 pancakes and the producer of the pancake is expected to produce a maximum of 12 pancakes within the given time. The whole of this thing is to happen within only 20 seconds and then the program should be terminated and print out the report after the 20 seconds. The Instruction was also that I should make the two things to run concurrently but not to use Thread or ExecutorService. I really need help some help on how to achieve it. Here is what I tried and I am getting an infinite loop on the producePancake method, it doesn’t even allow the eatPancake method to execute.

public class PanCakeTask {

int consumedPancake = 0;
int availablePancake = 0;
int totalPancakeProduced = 0;
List<String> usersList = new ArrayList<>();

 void producePancake(HashMap<String,Integer>users){
    // first check the total pancake produced so far by checking the number
    // of pancakes eaten by the users plus the available ones

    for (String user: users.keySet()){
        consumedPancake +=users.get(user);
    }
     totalPancakeProduced += consumedPancake + availablePancake;

    while (totalPancakeProduced <12){
        //only continue with the production of pancakes if the number of pancakes
        //produced has not been exhausted (i.e 15)

        System.out.println("Pancake produced");
        //increment the number of pancakes available
        availablePancake +=1;

    }
}
 void eatPancake(HashMap<String,Integer>users){
    //first pick the user at random
    Collections.shuffle(usersList);

    int numberEaten = users.get(usersList.get(0));
    //get the user that is on index zero after the list has been shuffled
    //then check how many pancake that the picked user has eaten
    //because each user is expected to eat a maximum of 5 pancake

    if (numberEaten ==5){
        //This means that this user has exhausted his/her quota so he/she cannot
        //be allowed to eat again
        //In this case, the eatPancake method is called again to randomly pick another user
        //I am thinking of removing the user from the list here so that he/she cannot be picked again
        eatPancake(users);
    }else {
        //Meaning that the user still has some quota left for him/her to eat
        //In this other condition, it will check if there is an available pancake produced

        if (availablePancake >=1){
            //user will now eat the pancake
            //then increment the number of pancake eaten by that user
            // and decrement the number of pancakes available

            int newCount = numberEaten + 1;
            availablePancake -=1;

            //finally update the user that just eaten the pancake
            users.put(usersList.get(0),newCount);
            System.out.println("Eaten a pancake");
        }
    }
}
public void performTask(){

    //Hashmap is used to store the users because of key-value pairs
    HashMap <String,Integer> users = new HashMap<>();
    users.put("user1",0);
    users.put("user2",0);
    users.put("user3",0);

    usersList.addAll(users.keySet());

    System.out.println(users);
    System.out.println(usersList);


    //This task can only be executed in 20 seconds

    long startTimeInSeconds = System.currentTimeMillis()/1000;
    long requiredTime = startTimeInSeconds +20;

    while (startTimeInSeconds !=requiredTime){
        //only continue the process if it has not exceeded 20 seconds
        System.out.println("Start time is "+startTimeInSeconds);
        System.out.println("End time is "+requiredTime);

        //This two method is to be executed concurrently without using Thread or ExecutorService
        // I need help on how to achieve that without the use of Thread or ExecutorService
        producePancake(users);
        eatPancake(users);
        startTimeInSeconds = System.currentTimeMillis()/1000;

    }
    System.out.println("Total number of cake produced is "+totalPancakeProduced);
    System.out.println("Total number of cake eaten is "+consumedPancake);
    System.out.println("Total number of pancake remained is "+availablePancake);
    System.out.println("Time start is "+startTimeInSeconds);
    System.out.println("Time completed is "+requiredTime);
}

}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật