Page 1 of 1

1- What is the difference between a thread and an object? An Object is a representation of a class that is used to expla

Posted: Tue May 24, 2022 7:54 am
by answerhappygod
1 What Is The Difference Between A Thread And An Object An Object Is A Representation Of A Class That Is Used To Expla 1
1 What Is The Difference Between A Thread And An Object An Object Is A Representation Of A Class That Is Used To Expla 1 (47.14 KiB) Viewed 16 times
1- What is the difference between a thread and an object? An Object is a representation of a class that is used to explain the class's state and behavior. A class's instance is an object. Objects can be used to access all of the class's data members and member functions. When a class is defined, no memory is allocated; nevertheless, memory is allocated when it is instantiated. In Java, a Thread is the path taken by one program throughout execution. The main thread is one of the threads in Java that is responsible for program execution. A thread is the path taken by the Java Virtual Machine (JVM) when the main method is invoked with the main thread. Java programs have at least one thread, known as the main thread, User threads & Daemon threads, Java Virtual Machine (JVM) at the program's start when the main method is invoked with the main thread. 2- Why daemon threads are needed? Daemon threads are needed in java because they are very useful for supporting tasks which are garbage collection and releasing the memory that is unused in objects and as well as removing unwanted entries from caches. Which is very important to maintain tasks in java.