What is thread?
Answers were Sorted based on User's Feedback
Answer / l.gururajan
Thread is a path of the execution in a program.
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / naveen
A thread is a part of program that follows a separate path of execution.
A thread is also called a light weight process as they share common resources
Is This Answer Correct ? | 4 Yes | 0 No |
Threads are lightweight process which lives inside process. These are independently running programs which have concurrent path of execution. Each thread has its own 1. Java stack 2. Program counter and 3. Native stack but have common heap space. Multiple threads with in same process share same variables and objects. They allocates objects from same heap and even they can share same instructions (execution code) at particular time. As a result above common access they can easily share information to each other.
Every program has at least one thread i.e. main thread. JVM creates main thread which calls main method to execute whole program. The main thread is non-daemon thread. Any thread created by main method is non-daemon thread by default.
JVM has daemon threads for garbage collection, object finalization and other housekeeping jobs.
Is This Answer Correct ? | 0 Yes | 0 No |
What is a stringbuffer?
public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod
How 'java' got its name and what it stands for?
Can we declare main () method as non static?
Which class is the immediate superclass of the Container class?
What is the preferred size of a component?
What is function overriding and overloading in java?
what is d difference between deep cloning and shallow cloning in core java?
Why static functions are used?
Is null a value?
What is the different types of functions?
How do I remove a character from a string in java?