what is a thread?

Answer Posted / venod.r.g

Thread is a class which extends Thread class or Implements
Runnable Interface.
Thread can run as an Independant process than current
Excecution steps. The Main thread that runs always is known
as CurrentThread accessed by Thread.currentThread();
Only one thread can access CPU time ( JVM then CPU). Multi
thread mechanisum is possible by making several threads in
waiting state and running only one at a time.

JVM assign priorities for every threads and accesses in a
Time Slicing / scheduled way considering the OS.

Defauls is normal.

Every object is like a Football to threads. hence Every
object must have methods to handle a thread. All the
players may be running in the field but only one player can
handle the Ball at a time. Object have methods like wait(),
notify() notifyAll() etc to catch and release the working
thread.

If you do not want a ball to change shape once it is
accessed by a thread then you need to synchronise the
statements or methods. Once synchronized the thread which
is the owner of the Object can only change the state of the
object.
//Method
public void synchronized x(){
}

//statement
synchronized (x);

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is thread life cycle?

540


Which category the java thread do fall in?

573


What are the access modifiers available in java?

562


Can we overload run() method in java?

597


Why do I need to declare the type of a variable in java?

566






Is 0 an irrational number?

602


What is return null in java?

509


What are void pointers?

714


Why is java architectural neutral?

615


Are arrays immutable in java?

543


What is a finally block? Is there a case when finally will not execute?

549


What is an abstract method in java programming?

604


How many boolean functions are there?

507


What is double parsedouble in java?

544


How can we break singleton in java?

523