The following scenario creates an console application that supports two threads. The application consists of three classes: Class1, Coffee, and Tea. Class1 contains the application’s main()method and code to start two threads — one to run the code for the Coffee class and one for the Tea class.
To create a multithreaded console application
Your .java file is now loaded in the Text editor and ready for modifications.
To add the Coffee and Tea classes to Class1.java file
Class1’s closing brace, “{“, enter the code found in Coffee and Tea Source Code.main() method, insert the following code:Coffee m_Coffee = new Coffee(); //creates Coffee object
m_Coffee.start(); //creates thread for Coffee object
new Tea().start(); //creates Tea object and its thread