When you create a Thread in Java, you only need to use the start() method to start the thread running in the background (you do not need to call the Thread's run() method directly). Try the following changes:
Code:
Thread kickThread = new Thread() {
public void run() {
int i = 0;
for (; i < 20; i++) {
if (i == 1) {
setKickAngle(RobotMap.kickDefaultAngle);
doneKicking = false;
} else if (i == 4) {
setKickAngle(RobotMap.kickHitAngle);
doneKicking = false;
} else if (i == 15) {
setKickAngle(RobotMap.kickDefaultAngle);
doneKicking = true;
}
Timer.delay(0.05);
}
doneKicking = true;
// CHANGE 1: Thread will terminate here, you don't need to try and have your thread interrupt itself
// kickThread.interrupt();
}
};
public void autoKick() {
// CHANGE 2: You only need to start your thread once per kick,
// its run() method will be done in the background
if (!kickThread.isAlive()) {
kickThread.start();
}
}