When I start new thread in traditional constructor, NetBeansIDE gives no warnings:
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
(new SomeThread()).start();
}
});
But if I convert it to Lambda expression, I'm getting a warning "Starting new Thread in constructor":
addActionListener((ActionEvent e) -> {
(new SomeThread()).start();
});
What is the problem here? What is the correct solution?
EDIT 1:
The same problem on NetBeans IDE 8.0.2:
The code:
import java.awt.event.ActionEvent;
import javax.swing.Timer;
public class TimerClass extends Timer {
public TimerClass() {
super(1000, null);//Loop 1 sec
addActionListener((ActionEvent e) -> {
(new SomeClass()).start();
});
}
private class SomeClass extends Thread {
@Override
public void run() {
}
}
}