Thermal instability in cooling flows