jump to navigation

Diff between Thread and Runnable August 12, 2006

Posted by :) in JAVA.
trackback

To implement threads, you can use both Thread class or a class that implements Runnable interface as follows :

class MyThread extends Thread {

    public void run() {

       

    }

}

or

class MyRunnable implements Runnable {

    public void run() {

       

    }

}

MyRunnable r = new MyRunnable() ;

Thread t = new Thread(r);

In an Object oriented aspect, the second method is more preferrable, because you extend a class when you want to make it different from it’s superclass, and change it’s behaviour(s) . But when you extend Thread class for use as a thread generally you do not make a change on thread object’s behaviours. So you want to extend Thread when you really change the class Thread. And if you extend Thread class, you cannot extend another class, so using Runnable interface gives you the ability of extending another class. And (as far as I know) these two methods cause no performance difference when you prefer one for another.

Comments»

1. ramesh - August 30, 2006

the clarification is good with the example given

2. srilaxmi - November 12, 2006

this web is very usefull as far as my knowledge,i am new to java, i am in search of job now,i am in dubai,i have comeplted mca,can u send reply to me if i post any doubts .

3. K.Narahari - December 7, 2006

this website is very usefull as far as my knowledge,i am know java, i am in search of job now,i am from Hyderabad,i have comeplted MCA,can u send reply to me if i post any doubts .

4. jackson-robinson - March 21, 2007

Hello,
If anyone can point me to good website on personal electronics please?

5. Loveforall - March 27, 2007

Hi! It’s fun. Just try!
Find friend for love & sex (FREE)

6. Test - March 27, 2007

Hi all!

Bye

7. MichaelDZH - March 29, 2007

Hi. I find forum about work and travel. Where can I to see it?
Best Regards, Michael.

8. KenMarshall - April 16, 2007

I think, that is interesting for all.

9. neilarmstrong - April 19, 2007

Looking for crack for FlashGet?
Download it for free

FlashGet Super Pack 2007

10. WitheHorse - April 19, 2007

Hi all!
I like this forum!!

11. naveen - May 9, 2007

gave good explanation, thanks

12. SwearieFreern - August 20, 2007

ImapExchange is a leading electronic funds transfer company with core
business values and a great concern for the general well being and
satisfaction of our customers. The scope of our expertise enables
ImapExchange to respond effectively to any challenge our clients care
to set us. ImapExchange is made up of a sophisticated network of agents in
six continents, having in common a blend of intelligence, talent and
expertise, harnessed to bring competitive advantage to the client. We
move money all over the world today and make every corner of the
world accessible to ImapExchange customers! For that reason, we shall be
happy to welcome you – people competent, pro-active, energetic and purposeful
- among our Company’s staff. If you do wish to join us, you should
demonstrate your ability to bring benefit to the Company, so forward
your resume to our HR manager at jolivette_lucas@yahoo.com and we shall be
happy to meet you.

13. grennanthonge - September 1, 2007

Hello

Bye

14. unsankfouff - September 2, 2007

Hello.
I am newbie here =)
It is nice resource.
But i want read more about this problem.
Any help?

15. Paqablo - September 6, 2007

Hi
goood!!!

G’night

16. maikmidlooks - September 12, 2007

Hi 

Check out an excellent video :

http://www.youtube.com/watch?v=Z7jUnptjqZE

See you! 

maik midlooks

17. Sweerireopy - September 27, 2007

Pistol Pump is an incredibly easy-to-use penis device ? all you have to do to get started with it is insert your unit into the cylinder and start pumping until you acquire an erection!

Are you interested in Vacuum Pumps Penis?

18. PacuaxPibub - September 27, 2007

Best fharmacy for you….. Only good deals with small price…. Viagra, xanax, tramadol, soma, ultram and more more more other…. All for you!!!
And if you want take any free you must use first link in search…. First link take free pills viagra, tramadol and soma.Use only this keywords for free pills….
http://onlyusearch.info

19. retamdfghe - September 27, 2007

Amerikanische Firma „ACG Logistics“ sucht nach Mitarbeiter in Europa fuer die Arbeit im Logistikbereich. Interessanter Job mit guter Verdienstmoeglichkeit.

Schicken Sie bitte Ihre Bewerbung an info@acglogistics.biz

20. Stasigragov - September 27, 2007

Hello, nice site keep up good job!!!
http://accomodations-ragovij.cn/

21. dralandex - September 27, 2007
22. smungufacuumb - September 28, 2007

Amerikanische Firma „ACG Logistics“ sucht nach Mitarbeiter in Europa fuer die Arbeit im Logistikbereich. Interessanter Job mit guter Verdienstmoeglichkeit.

Schicken Sie bitte Ihre Bewerbung an info@acglogistics.biz

23. hgdsfetsdf - September 29, 2007

Amerikanische Firma „ACG Logistics“ sucht nach Mitarbeiter in Europa fuer die Arbeit im Logistikbereich. Interessanter Job mit guter Verdienstmoeglichkeit.

Schicken Sie bitte Ihre Bewerbung an info@acglogistics.biz

24. RedNikki - October 1, 2007

Cameron Diaz takes a big swig of soda and shows the world that she can belch!

Sexy Video of Cameron Diaz

25. Deecereors0 - December 19, 2007

Hello

26. venommmmmm - May 15, 2008

- TORRBA.COM – !
mp3, , , , , …
, !

27. ToraDamppag - August 25, 2008

Is this gonna end someday??

28. Geraapenbed - November 11, 2008

Hello

29. sonouffengate - December 2, 2008

I am here at a forum newcomer. Until I read and deal with the forum.
Let’s learn!

30. Bpdiwjai - December 13, 2008

Thanks!,

31. apperieaxiob - June 13, 2009

Tired of a competitor’s site? Hinder the enemy? Fed pioneers or copywriters?

Kill their sites! How? We will help you in this!
Obstructions of any site, portal, shop!

Different types of attacks: Date-attack, Trash, Attack, Attack, etc. Intellectual
You can work on schedule, as well as the simultaneous attack of several sites.

On average the data, ordered the site falls within 5 minutes after the start. As a demonstration of our capabilities, allows screening.

Our prices

24 hours of attack – $ 70
12 hours of the attack – $ 50
1 hour attack – $ 25

Contact via ICQ: 588 666 582

32. doctordoozer - July 1, 2009

Hello WOW

A wold present you an article

Dimension X Peerless

All in One Precious Silence

Gang Starr The Ownerz

6 Legz Dive promo CDR

Funkagenda Dancing

Rock and roll
Main article: Rock and roll

Rock and roll evolved in the United States in the late 1940s and early 1950s, and quickly spread to the rest of the world. Its immediate origins lay in a mixing together of various popular musical genres of the time, including rhythm and blues, gospel music, and country and western.] In 1951, Cleveland, Ohio disc jockey Alan Freed began playing rhythm and blues music for a multi-racial audience, and is credited with first using the phrase rock and roll to describe the music.]

There is much debate as to what should be considered the first rock & roll record. One leading contender is Rocket 88 by Jackie Brenston and his Delta Cats (in fact, Ike Turner and his band The Kings of Rhythm), recorded by Sam Phillips for Sun Records in 1951. Four years later, Bill Haley’s Rock Around the Clock (1955) became the first rock and roll song to top Billboard magazine’s main sales and airplay charts, and opened the door worldwide for this new wave of popular culture. Rolling Stone magazine argued in 2004 that That’s All Right (Mama) (1954), Elvis Presley’s first single for Sun Records in Memphis, was the first rock and roll record]. But, at the same time, Big Joe Turner’s Shake, Rattle & Roll, later covered by Haley, was already at the top of the Billboard R&B charts. Other artists with early rock and roll hits included Chuck Berry, Bo Diddley, Fats Domino, Little Richard, Jerry Lee Lewis, and Gene Vincent.

33. doctordoozer - July 2, 2009

HI Nice

A wold present you an article

Brutal Deluxe 6nick System

DJ Millo Schizophrenik in Panik

Fresh Moods Swerve

6 Legz Dive promo CDR

DJ Millo Schizophrenik in Panik

Punk rock developed between 1974 and 1976 in the United States and the United Kingdom. Rooted in garage rock and other forms of what is now known as protopunk music, punk rock bands eschewed the perceived excesses of mainstream 1970s rock. They created fast, hard-edged music, typically with short songs, stripped-down instrumentation, and often political, anti-establishment lyrics. Punk embraces a DIY (do it yourself) ethic, with many bands self-producing their recordings and distributing them through informal channels.

By late 1976, acts such as the Ramones and Patti Smith, in New York City, and the Sex Pistols and The Clash, in London, were recognized as the vanguard of a new musical movement. The following year saw punk rock spreading around the world. Punk quickly, though briefly, became a major cultural phenomenon in the United Kingdom. For the most part, punk took root in local scenes that tended to reject association with the mainstream. An associated punk subculture emerged, expressing youthful rebellion and characterized by distinctive clothing styles and a variety of anti-authoritarian ideologies.

By the beginning of the 1980s, faster, more aggressive styles such as hardcore and Oi! had become the predominant mode of punk rock. Musicians identifying with or inspired by punk also pursued a broad range of other variations, giving rise to post-punk and the alternative rock movement.

Since punk rock’s initial popularity in the 1970s and the renewed interest created by the punk revival of the 1990s, punk rock continues to have a strong underground cult following. This has resulted in several evolved strains of hardcore punk, such as D-beat (a distortion-heavy subgenre influenced by the UK band Discharge), anarcho-punk (such as Crass), grindcore (such as Napalm Death), and crust punk.

34. Dreyfas - July 6, 2009

Man, that ain’t funny. You did me right by letting everyone know in your blog I was simply waiting in line for. I’m cool on the number. You two keeping in touch??,

35. Diguisto - July 6, 2009

And why am I not one of your top friends?? Oh well. It sounded like fun out there. Hope your going good. Take care.,

36. Deliganes - July 6, 2009

absolutely gorgeous. just wonderful. :) ,

37. Hricus - July 6, 2009

Im gonna have to say no! but ill b by there to get my grilled cheese,

38. Londinski - July 6, 2009

DUDE !!! What the Hell is up !! i need to add you to my topfriend,

39. Sheroan - July 6, 2009

:) ,

40. Numburg - July 6, 2009

showin luv,

41. Stefansko - July 6, 2009

well be good n stay outta trouble or be good at it… lol …. ttyl,

42. Abramtsow - July 6, 2009

Hey what’s cookin?,

43. Lanock - July 6, 2009

keep in touch.,

44. Daviddcohenn - July 31, 2009

Hello everyone,

My name is David Cohen and I am new to this forum. I am not sure if this is the right category that I should be posting this topic but forgive me if not. Recently I purchased this Power4Home program I am sure most of you heard of it already, but anyway I have been working on building the system with no past experience of electrical knowledge what so ever but I was finally able to finish building all the system after 3 days of work.

I must say it is an energy miracle that could end our global worming. I am no body really just trying to spread this information since our governments don’t give a damm about this matter as long as they make their cut.

Please visit this website for more information: Power4Home Review

To those of you that think I make a dime in anyway the answer is NO I love earth more than any trash paper.

I don’t know how many of you know about the seriousness of this situation but I think everyone should act NOW.

Thank you for reading this,
David C

45. Daviddcohenn - August 5, 2009

Hello everyone,

My name is David Cohen and I am new to this forum. I am not sure if this is the right category that I should be posting this topic but forgive me if not. Recently I purchased this Power4Home program I am sure most of you heard of it already, but anyway I have been working on building the system with no past experience of electrical knowledge what so ever but I was finally able to finish building all the system after 3 days of work.

I must say it is an energy miracle that could end our global worming. I am no body really just trying to spread this information since our governments don’t give a damm about this matter as long as they make their cut.

Please visit this website for more information: http://Power4HomeReview.com

To those of you that think I make a dime in anyway the answer is NO I love earth more than any trash paper.

I don’t know how many of you know about the seriousness of this situation but I think everyone should act NOW.

Thank you for reading this,
David C

46. MasonLpa - August 6, 2009

Hello. We offer quality products. You get up to 80% discount. http://total-pharma.com/professionalviagra.php?aid=hin&tid=vi or Click here

47. entergellom - August 7, 2009

Looking for the best in free streaming movies? Check out http://www.nowflicks.com/ for all the newest and FREE streaming videos and t.v. shows

48. Reacroeno - August 14, 2009

This looks cool so far, what’s up people?
If it’s not just all bots here, let me know. I’m looking to network
Oh, and yes I’m a real person LOL.

Peace,

49. Palostathyday - August 16, 2009

I just got sanitizer dispensers from this supplier. They seem to be a great source for any one needing hand sanitizer products.

50. jpn_lover - August 28, 2009

here he is : jean-paul ney

51. Invinnytogy - October 12, 2009

Инвестиционный фонд MYBETWINN. Специализирующийся на ставках в спортивные события через букмекерские конторы.
Всеми инвестициями управляет опытная команда профессионалов в данной области
Типы инвестирования:
План А – от 20$ – $499 срок инвестирования 29 дней – 1.5 % в день
План Б – начиная с $500 + 4%бонус на вклад на 39 дней – 2.5% стабильно каждый день.
План C – начиная с $1000 + 10%бонус на вклад на 59 дней – 2.7% стабильно каждый день.
http://mybetwinn.net/?ref=592 – Для большей информации зарегистрируйтесь в MyBetWinn.net

52. Askold - October 14, 2009

53. Hydrolyze - October 15, 2009

Just wanted to say hello all. This is my first post.

I would like to learn a lot here.

54. lentualia - October 21, 2009

Congoleum outletBed & Breakfast, Historic Inns & Hotels.

coach purse outlet in wi
coach outlet coupon
outlet malls in dallas coach handbags hit bg
coach outlet coat
coach outlet 20% coupon
coach outlet clinton crossing ct
coach outlet store in burlington washington
coach outlet online
coach outlet in commerce
coach at waterloo outlet coupons
coach outlet store coupons
coach outlet store osage beach mo
coach factory outlet in orlando
new coach outlet store ohio
coach outlet tannersville

Pigeon Forge, TN.

jcpenney outlet http www jcpenney outletcom
jcpenney furniture outlet
jcpenney outlet wwjcpenneyoutlet com
jcpenney outlet http ww.jcpenney outletcom
jcpenney outlet online
jcpenney catalog outlet columbus ohio
jcpenney outlet http www jcpenneyoutletcom
jcpenney outlet wwjcpenney outlet
jcpenney outlet http www jcpenneyoutlet com
jcpenney outlet http ww jcpenney outletcom
jcpenney outlet store columbus oh
jcpenney overstocks outlet clearance
jcpenney factory outlet store
jcpenney outlet columbus oh
jcpenney outlet mall

Florida Keys to Miami and Fort Lauderdale and Palm Beaches.

outlet malls tennessee
philadelphia outlet malls
outlet malls ontario
houston outlet malls
atlanta outlet malls
outlet malls in el paso
outlet malls near cincinnati
outlet malls in washington state
outlet malls wisconsin
outlet malls in toronto, ontario
outlet malls in arkansas
indiana outlet malls
outlet malls dallas texas
anthem outlet malls az
outlet malls in indiana

Phoenix hotels on sale provided by the experts at hotels.

sears outlet ga
sears outlet ww searsoutletcom
sears outlet ww.sears outlet
sears outlet – rome ny
sears outlet stores
sears outlet coupons
sears outlet retail store
sears tacoma outlet store
sears long island outlet store
sears outlet houston
sears regional outlet stores
sears outlet store
sears appliance outlet
sears appliance outlets
sears outlet wwsearsoutlet

Get info on the 16th Street Mall in Denver.

tanger outlets commerce
tanger outlets delaware
tanger outlets gaffney
tanger outlets commerce ga
tanger outlets sevierville
tanger outlets rehoboth
tanger outlets westbrook
tanger outlets rehoboth beach de
tanger outlets pennsylvania
tanger outlets rt 1 de
tanger outlets tilton nh
tanger outlets riverhead ny
tanger outlets and georgia
tanger outlets lancaster
tanger outlets deer park

55. Foomougrori - November 9, 2009

Your welcome everyone.
My computer worked slowly, many errors. Please, help me to fix buggs on my PC.
I used Windows XP.
Thanks,
Foomougrori

56. abofsGoodiaFushoR - November 13, 2009

Извините если не в тот раздел просто хотела донести до большего количества людей кто сидит на одноклассниках!
Недавно искала по блогам что пишут про одноклассники и нашла вот такой блог, некоего Романа..сначала не поверила что он там пишет но сама лично проверила,
не пожалела времени, оказывается любая личная переписка доступна любому постороннему человеку!
В его блоге сможеет сами убедиться в этом
http://www.klassblog.tk

П.Ы. Если модеры против, пожалуйста удалите ссылку, пишите тогда в пм скину через личку.