The following code snippet supports the creation of the Multithreaded Beverages Application. The following Coffee and Tea classes extend the Thread class which allows them to run on separate threads.
class Coffee extends Thread
{
public void run()
{
for(int i = 0; i < 10; i++)
{
System.out.println("I Like Coffee" + " " + i);
yield();
}
}
}
class Tea extends Thread
{
public void run()
{
for(int i = 0; i < 10; i++)
{
System.out.println("I Like Tea" + " " + i);
yield();
}
}
}