In this case, every car checks whether there is a car somewhere in front of it or not. If there is one, the car will brake depending on how far the other car is away. Quite similar with the traffic lights and their stop lines.
Then you should try out Traffic Simulation 2 (http://www.greenfoot.org/scenarios/13356) and Traffic Simulation 3 (http://www.greenfoot.org/scenarios/15117). They are much better than this. ;)
2013/6/4
2013/6/4
2013/6/9
2013/6/10
2013/6/25
2014/8/22
2014/8/22
2016/2/4
2016/2/4