adspace


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

Explain public static void main(string args[]) in java.

1078


What is java string pool?

1084


What is a classloader in java?

1091


Realized?

2266


What is an object in java and how is it created?

1141


How to sort array in descending order in java?

997


Write a program to find the whether a number is an Armstrong number or not?

1101


explain different ways of using thread? : Java thread

1084


Is minecraft 1.15 out?

1046


What is the difference between equals() and == in java?

1042


Differentiate between static and non-static methods in java.

1129


Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example

2666


What is the difference between break and continue statements?

1128


What do you mean by an interface in java?

1105


What is a constructor overloading in java?

1126