FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Runnable and Thread





akshar
Can anyone tell me the diffrence between two java classes which are inherited to create userdefined threads

Runnable and Thread.

Secondly tell me the use of synchronized keyword in Java.
poppitz
Hi,

Thread is a class and Runnableis an Interface which is implemented by the class Thread. So if you want to create create a multithreaded application you can either build a subclass of Thread or implement the interface Runnable.

synchronized is used to define mehtods that should only be used from one Thread at the same time. You can use it like this:

Code:
public synchronized void foo() {...}


If one Thread calls foo all other Theads have to wait until it has finished.
Related topics
Love Is Just a Thread
Humour thread - Be Happy
Official, what are you listening to at the moment thread!
What's your favourite colour?
Make an official free game thread
Thread
Ashens Web Design Questions Thread
Why does EVERY "Favorite" thread get locked now?
Need Advice on a girl (interesting thread)
image at the end of the thread
Can I open a thread in the marketplace about..
a graphics thread
Sorry to break a forum rule. A new language thread.
Sorry to break a forum rule. A new language thread.
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.