When more than half your citizens are unhappy (go to your city screen, and mouse over your laborer's heads. If 6/11 or 5/9, etc, are unhappy, the city will riot!), a city will riot until you fix the problem. Usually, the early game, since food and working tiles is important, you should use the luxury slider (the slider by the happy face on the F1 screen) - plus, this will affect all your cities, not just one city, like a specialist. Later on in the game, when changing a laborer to a specialist won't hurt the city, it is ok to use specialists. Lots of times cities will riot the turn after they grow since they now have more unhappy laborers than happy and content ones - so watch your cities every turn, especially ones that just grew, to make sure they don't riot.
PS: When using the luxury slider, the more commerce your city produces, the more citizens will be happy.