Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Ravi Vishwakarma
24-Apr-20251. Extending
Thread
classExample:
Notes:
run()
contains the code to be executed in the new thread.start()
creates a new thread and then callsrun()
internally.2. Implementing
Runnable
interfaceExample:
Why use
Runnable
?3. Using Lambda (Java 8+)
If your logic is simple, you can use a lambda expression instead of writing a separate class.
Example:
Summary:
extends Thread
implements Runnable
Bonus: Sleep, Join, and Priority