I studied the concept of multithreading in Java, where I met this very interesting behavior. I experimented with various ways to create a stream. The current issue is that we are expanding Thread without implementing the Runnable interface.
On the side of the note, I know that it makes the perfect OO sense for implementing the Runnable interface, and not for extending the Thread class, but for the purposes of this question, suppose we extended the Thread class.
Let t be my instance of my extended Thread class, and I have a block of code that will execute in the background, which is written in my run() method of my Thread class.
It works fine in the background with t.start() , but I'm a little curious and called t.run() . The piece of code executed in the main thread!
What does t.start() that t.run() does not work?
source share