Can we call thread_object.start() from within a constructor of this same object?
Is this approach a good idea ?
You can do that, but it is considered as bad practice. There is one paragraph about starting Threads in constructors in this article.
AS nicerobot stated in the comments, your question seem to be a duplicate of this. Have a look at Heath Borders answer there.
Just out of interest - why do you extend Thread? Why not implement Runnable instead, you get more flexibility (e.g. can be executed within a thread you create or an ExecutorService, which is the preferred method).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With