0

Hi,
I have java code, in the code there is about 5 lines that I wont to open in new Thread, I don't wont to crate all new class for 5 lines , can I can I implement the Thread inside the method without new class?

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by stewie griffin
0

You can have the class extend the Thread class.
If you don't want to change the code of the old class though you can try to create a new one that extends the old and implements the Runnable interface:

Runnbale

public NewClass extends OldClass implements Runnable {
   
  public void run() {
      ......
  }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.