Alex Rivera | Logout

calling thread.start() within its own constructor

Asked 2008-09-17T15:11:33.940
10

is it legal for a thread to call this.start() inside its own constructor? and if so what potential issues can this cause? I understand that the object wont have fully initialized until the constructor has run to completion but aside from this are there any other issues?

Edit
Report

1 Answer

1

It's legal, but not wise. The Thread part of the instance will be completely initialised, but your constructor may not. There is very little reason to extend Thread, and to pull tricks like this isn't going to help your code.

answered 2008-09-17T15:14:57.740

Your Answer