+ 2
Threads? What does it mean...
class hii extends Thread { public void run() { System.out.println("Hello"); } } class MyClass { public static void main(String[ ] args) { hii obj = new hii (); // ^^^ What does this line do? obj.start(); } } // Why use threads? // Wouldn't it work just fine without threads?
2 Answers
+ 3
I think of threads like hands. I can work with more than one thing at the same time with the more hands that I have. Basically, threading allows you to create additional processes within a process.
+ 1
Typical situations are background processes. Like calculations, database access. Anything that takes long. You don't want to stop your program till that is finished. So execute them on another thread.