public class Test {
public static void main(String[] args) {
Thread t1 = new Thread();
Thread t2 = new Thread();
Thread t3 = t1;
String s1 = new String();
String s2 = new String();
System.out.println(t1 == t3); //true
System.out.println(t1 == t2); //false
**System.out.println(t1.equals(t2)); //false**
System.out.println(s1.equals(s2)); //true
}
}
As we know, Object.equals()
method is used for checking the content rather than the reference. So when you create two threads and perform equals()
on them, what exactly is happening?
I assumed threads work differently. (I'm a beginner)
How do they work?