En la linea 13 (dormir = true;) me dice el
Syntax error on token "dormir", VariableDeclaratorId expected after this token.
import java.io.IOException;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class Comprobacion {
public static void main(String[] args) throws IOException {
boolean dormir = false;
TimerTask task = new TimerTask() {
dormir = true;
int cont = 0;
@Override
public void run() {
cont++;
System.out.println("Contador: "+cont);
}
};
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
int tiempoDeInicio = 1, tiempoDeIntervalo = 1;
scheduler.scheduleAtFixedRate(task, tiempoDeInicio, tiempoDeIntervalo, TimeUnit.SECONDS);
}
}