Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

threads

0 views
Skip to first unread message

Matthias Jung

unread,
Jan 16, 1998, 3:00:00 AM1/16/98
to

hello all,

i wonder if i should realized threads by
1) extending the Thread class or
2) implementing the Runnable interface and start them with (new
Thread(myThreadObject)).start()

what are the pros and cons? can anybody help me?
for case 2): how can i still keep control about my own defined member
variables and methods?

thanks
matthias

--
Matthias Jung
Institut Eurecom
2229 Route des Cretes; BP 193
F-06904 Sophia Antipolis Cedex

Tel: +33 4.93.00.26.31
E-mail: ju...@eurecom.fr
http://www.eurecom.fr/~jung/

Thomas A. McGlynn

unread,
Jan 16, 1998, 3:00:00 AM1/16/98
to

Matthias Jung wrote:
>
> hello all,
>
> i wonder if i should realized threads by
> 1) extending the Thread class or
> 2) implementing the Runnable interface and start them with (new
> Thread(myThreadObject)).start()
>
> what are the pros and cons? can anybody help me?
> for case 2): how can i still keep control about my own defined member
> variables and methods?
>
> thanks
> matthias
>
> --
> Matthias Jung


Use Runnable.

Extend Thread only when you want to extend the capabilities of
threads, i.e., when you are going to do something like:

ExtendedThread(aRunnableObject).start();


Why? Because the whole idea of inheritance is that the subclass
is some kind of specialization/extension of the parent.

I'm not sure I understand your question about controlling
your member variables and methods. The only thing that the
Runnable interface requires is that your class have a run method.
Otherwise you are free to design the class in any way you wish.

Hope this helps,

Yours,
Tom McGlynn
t...@silk.gsfc.nasa.gov

0 new messages