GuruKulki GuruKulki - 8 days ago 4
Java Question

Why can't we call the start method twice on a same instance of the Thread object?

I was reading about threads and found that we can't call the start method twice on the same thread instance. But I didn't understand the exact reason for the same. So why can't we call it twice or even more times?

Answer

In my opinion the Thread object is your "handle" for the actual running context. If you allow creating many concurrent executions associated with the same java.lang.Thread, what would you expect getStackTrace() and getState() methods to return?

I suppose that Thread class could have been designed to allow spawning multiple running contexts, but its API would be less simple and clean.