Hallo! Vom Prof angeraten, hab ich mal Eclipse beiseite gelegt und BlueJ ausprobiert. Nur scheint bei den Einstellungen iwas nicht zu stimmen, denn ein Code wie dieser hier:
Alles anzeigen
lässt sich nicht ausführen. Denn wenn ich die main-Methode aufrufe und dann ausführen will (also auch ohne übergebene Argumente), kommt das hier:
"Error: Cannot find symbol - variable ThreadHelloCount"
Das Ganze funktioniert übrigens in Eclipse einwandfrei.
Quellcode
- class ThreadHelloCount
- {
- public static void main(String args[])
- {
- HelloThread hello = new HelloThread();
- CountThread count = new CountThread();
- hello.start();
- count.start();
- }
- }
- class HelloThread extends Thread
- {
- public void run()
- {
- int pause;
- for (int i=0; i<5; i++)
- {
- try
- {
- System.out.println("Hello!");
- pause = (int)(Math.random() * 3000);
- sleep(pause);
- }
- catch (InterruptedException e)
- {
- System.out.println(e.toString());
- }
- }
- }
- }
- class CountThread extends Thread
- {
- int pause;
- public void run()
- {
- for (int i=0; i<5; i++)
- {
- try
- {
- System.out.println(i+1);
- pause = (int)(Math.random() * 3000);
- sleep(pause);
- }
- catch (InterruptedException e)
- {
- System.out.println(e.toString());
- }
- }
- }
- }
lässt sich nicht ausführen. Denn wenn ich die main-Methode aufrufe und dann ausführen will (also auch ohne übergebene Argumente), kommt das hier:
"Error: Cannot find symbol - variable ThreadHelloCount"
Das Ganze funktioniert übrigens in Eclipse einwandfrei.
FEHLER VERMEIDET MAN, INDEM MAN ERFAHRUNG SAMMELT. ERFAHRUNG SAMMELT MAN, INDEM MAN FEHLER MACHT.