return statement on a void?
Theres a part that i dont understand, and if its possible i'd like to be helped a bit with it ^_^.
This class is part of a program that uses threading to display a consistent "Tick Tock", but the part that i dont get is why is there a return statement on the method that is on bold, isn't void supposed to mean that it doesnt return a value, is the return statement just used to get out of the if loop?, or maybe something else! help is appreciated!
class TickTock{
[b]synchronizedvoid tick(boolean running){
if(!running){// stop the clock
notify();// notify any waiting threads
return;[/b]
}
System.out.print("Tick ");
notify();// let tock() run
try{
wait();// wait for tock() to complete
}
catch(InterruptedException exc){
System.out.println("Thread interrupted.");
}
}
synchronizedvoid tock(boolean running){
if(!running){// stop the clock
notify();// notify any waiting threads
return;
}
System.out.println("Tock");
notify();// let tick() run
try{
wait();// wait for tick to complete
}
catch(InterruptedException exc){
System.out.println("Thread interrupted.");
}
}
}
Message was edited by:
Rix87

