FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a 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.
Reply to topic    Frihost Forum Index -> Scripting -> Others

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