/*De klasse TickTock
-  één attribuut: boolean tickGebeurt = false
-  methode wachtOpTick()
-  methode tick()
*/

public class TickTock
{
	private boolean tickGebeurt;

	public TickTock()
	{
		tickGebeurt = false;
	}

	public void wachtOpTick()
	{
		while(tickGebeurt  == false)
		{
			try
			{
				this.wait();
			}
			catch(InterruptedException e)
			{
				e.printStackTrace();
			}

		}
		tickGebeurt = false;
		this.notify();
	}

	public void tick()
	{
		while (tickGebeurt == true)
		{
			try
			{
				this.wait();
			}
			catch(InterruptedException e)
			{
				e.printStackTrace();
			}
		}
		tickGebeurt = true;

		this.notify();
	}
}