/* 7.
Create a multi-threaded Java application that simulates any real time application with
required functionalities. For eg. Basic chat system in which each user (thread) sends and
receives messages. Use isAlive() to check the status of threads and join() to ensure proper
synchronization. Implement thread priorities to handle high-priority messages and demonstrate
thread suspension, resumption, and stopping. */ class MyThread extends Thread { public
MyThread(String name) { super(name); } public void run() { [Link](getName() + " is
starting."); for (int i = 1; i <= 5; i++) { [Link](getName() + " - Count: " + i); try {
[Link](500); // pause for readability } catch (InterruptedException e) {
[Link](e); } } [Link](getName() + " is finished."); } } class MyRunnable
implements Runnable { public void run() { String name = [Link]().getName();
[Link](name + " (Runnable) is starting."); for (int i = 1; i <= 5; i++) {
[Link](name + " (Runnable) - Step " + i); try { [Link](500); } catch
(InterruptedException e) { [Link](e); } } [Link](name + " (Runnable) is
finished."); } } public class MultiThread { public static void main(String[] args) { // Threads using
extends Thread MyThread t1 = new MyThread("Thread-1"); MyThread t2 = new
MyThread("Thread-2"); // Thread using Runnable Thread t3 = new Thread(new MyRunnable(),
"Runnable-Thread"); // Start all [Link](); [Link](); [Link](); // Wait until all threads finish try {
[Link](); [Link](); [Link](); } catch (InterruptedException e) { [Link](e); }
[Link]("All threads have finished execution."); } }