0

Note note = new Note(400,"short"); note.start(); //start the note thread

Vs

new Note(400,"short").start();

I thought both ways are same to make instance of the class. But only the first way above moves my note with thread... what's the difference between those two and why thread start method only works with the first one?

Samuel Yoo
  • 21
  • 2
  • 1
    There is no difference between those two versions. If only the first one works ... it is something else causing this. If we are going to help you, you will need create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that demonstrates the actual problem that you are seeing. – Stephen C Dec 23 '21 at 11:27
  • (This is not your problem, but creating subclasses of `Thread` is a bad idea. It means that you can't use a standard thread pool implementation. You should be either implementing the `Runnable` interface using a named or anonymous class, or using a lambda as the runnable. See https://stackoverflow.com/questions/541487) – Stephen C Dec 23 '21 at 11:31
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 02 '22 at 23:55

0 Answers0