Can wearing masks stop the spread of viruses?

Surgical masks have been used to prevent illness in China for decades.