Skip to content

Instantly share code, notes, and snippets.

View rajat499's full-sized avatar
👨‍💻

Rajat Jaiswal rajat499

👨‍💻
View GitHub Profile
@rajat499
rajat499 / BaseThread.java
Last active August 30, 2020 15:34
Extension to the classical problem of synchronization – the Dining Philosophers problem. Solved using the Monitor construct built on top of Java’s synchronization primitives. The extension here is that sometimes philosophers would like to talk, but only one (any) philosopher can be talking at a time while he/she is not eating.
import java.util.Random;
public class BaseThread extends Thread
{
/*
* ------------
* Data members
* ------------
*/