What happens if you call run() directly instead of calling start() on a Thread?
Calling run() directly simply executes the Runnable's logic synchronously on whichever thread made the call -- it behaves exactly like calling any ordinary method, and no new thread is created. start() is what actually creates and launches a new operating-system thread, which then calls run() asynchronously on that new thread. This is a common beginner mistake because it doesn't throw an exception or fail loudly: the code appears to work correctly, but it silently runs single-threaded on the calling thread, completely defeating the purpose of introducing threading in the first place.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response