BANGKOK — President Thein Sein of Myanmar said Thursday that he was prepared to use force to quell the religious rioting that has shaken his country, answering calls even from longtime democracy advocates for more forceful security measures.

“I am firmly committed to use the power to deploy the security forces vested in me by the Constitution,” Mr. Thein Sein said in a televised speech, his first public comments since anti-Muslim rioting in central Myanmar killed at least 40 people last week.

Mr. Thein Sein said the use of force would be a “last resort to protect the lives and safeguard the property of the general public.”