Page 1 of 1

Ich habe eine Thread -Variable in Java erstellt und habe diesen Fehler erhalten: Gamethread kann nicht auf eine Variable

Posted: 12 Apr 2025, 15:01
by Anonymous
Hi I got an error that is about the gameThread variable in my java code
is says:
"Exception in thread "Thread-0" java.lang.Error: Unresolved compilation problem: gameThread cannot be resolved to a variable"
any ideas
thanks for the help

Code: Select all

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;

public class GamePanel extends JPanel implements Runnable{

public void startGameThread(){
Thread gameThread = new Thread(this);
gameThread.start();
}
@Override
public void run(){
while(gameThread != null){

}
}

}
Ich erwarte, dass es funktioniert