I've been checking some technical stuff about Threads in Java and I'm a little bit confused about a specific issue when I define a thread with an anonymous class (proper use of parenthesis in the constructor definition). The regular declaration would be this one:
Thread myRunnableThread3 = new Thread(new MyRunnable(){
@Override
public void run() {
System.out.println("myRunnableThread3!");
}
});
myRunnableThread3.start();
And just for experimentation purposes, I tried this:
Thread myRunnableThread3 = new Thread(new MyRunnable()){
@Override
public void run() {
System.out.println("myRunnableThread3!");
}
};
myRunnableThread3.start();
As you may see, both look pretty similar and the output console it's the same. So, Am I missing something? maybe there is a little slightly functional difference that I'm not realizing yet. By the way, I'm using Java Corretto 11. Both look OK, maybe should I go for the first option? Thanks for your comments and help.