+ 1
Best way to create a thread
what is the best way to create a thread- by implementing Runnable or by extending Thread? and why?
2 ответов
+ 4
I prefer to implement Runnable and to be able to extends to other classes
0
There are no rules about which of the two methods that is best. Both are best. Personally though, I prefer implementing Runnable, and hadling en instance of the implementation to a Thread instance. When having the Runnable's executed by a thread pool it is easy to queue up the Runnable instances until a thread from the pool is idle. This is little harder to do with Thread sub classes.