When do silk worms form cocoons?
Bombyx mori
After they have molted four times, their bodies become slightly yellow and the skin becomes tighter. The larvae then prepare to enter the pupal phase of their lifecycle, and enclose themselves in a cocoon made up of raw silk produced by the salivary glands. The final molt from larva to pupa takes place within the cocoon, which provides a vital layer of protection during the vulnerable, almost motionless pupal state. Many other Lepidoptera produce cocoons, but only a few—the Bombycidae, in particular the genus Bombyx, and the Saturniidae, in particular the genus Antheraea—have been exploited for fabric production.
Thai silk
In its original cocoon form, raw silk is bumpy and irregular. Thai weavers separate the completed cocoons from the mulberry bush and soak them in a vat of boiling water to separate the silk thread from the caterpillar inside the cocoon.