By having different cues to bark and to be quiet, your dog will learn the distinction between the two faster while you gain much greater control over their barking habits. Some dogs are harder to train than others, so make sure that you don't give up if it takes longer than you expect to train the dog.
Dogs that bark constantly can be a major annoyance. Not only can a barking dog upset your life, but it can also bother neighbors as well. The only way that you can be sure that your dog isn't going to bark is to train him or her to stop barking upon command; a common method of issuing this command is with a dog whistle.
Remove the cause of the dog's barking--if at all possible--before you begin training. This could be as simple as closing the curtains so that the dog can't see your neighbor's cat (if that is what the dog barks at most frequently). Not all causes of barking can be removed, of course, but removing those causes can make training much easier.
Give a command word when the dog starts barking, repeating it several times until the dog barks again. When the dog barks, praise it and give it a treat. This is the portion of the training that may seem counter-productive at first; in order to properly train your dog to stop barking on command, it is much easier to first train the dog to bark on command.
Continue training the dog for several weeks with your command word. After the first week of the dog responding appropriately every time the command is given, only give a treat every other time that you give the command. Beyond that, give the treat much less frequently (but make sure to still give treats occasionally.) By this point your dog should begin barking any time that you give the command; it may have started barking less frequently as a result as well.
Give the command word to cause your dog to bark, then blow your dog whistle. Odds are this will have little effect on the dog at first, but continue blowing the whistle much like you repeated the command word at first. When your dog falls silent, give it a treat and praise it.
Continue training the dog with the whistle, giving it treats for the first week or two each time it correctly responds to the whistle. As the dog becomes more used to the whistle and begins to be quiet on demand, begin spacing out the treats much like you did with your command word to bark. Periodically repeat both the command word and whistle training to keep your dog trained, and don't forget to actually give treats as well as praise from time to time when the dog responds correctly to either the command word or the whistle.