This project demonstrates basic Java threading concepts using two different approaches:
- Extending the
Threadclass (MyThread.java) - Implementing the
Runnableinterface (MyRunnable.java)
- Thread creation and management
- Thread priority setting
- Fibonacci series calculation in separate threads
- Prime number checking functionality
- Thread state monitoring
- Extends
Threadclass - Creates multiple threads with different priorities
- Calculates Fibonacci series up to a specified number
- Includes prime number checking capability
- Implements
Runnableinterface - Takes user input for Fibonacci calculation
- Demonstrates basic thread creation and execution
To run the Thread class example:
java MyThreadTo run the Runnable interface example:
java MyRunnableMyThread will output:
- Main thread ID
- Thread IDs, names, and priorities
- Fibonacci series calculations
MyRunnable will:
- Prompt for user input
- Calculate and display Fibonacci series
- Show thread status