Thank you for your query on Healthcare Magic.
The thread like structures are intestinal worms.
Usually in gastroenteritis
because of disturbance in intestinal environment, worms expel from the rectum.
The thread like structure may be ascariasis
or segments of a tape worm.
Continue the medication as advised for diarrhea.
Maintain his hydration by giving sips of oral rehydration solutions like Pedialyte
Once the diarrhea got treated and controlled, go for Pediatrician
consultation for the treatment of worm infestation by giving deworming medicine in prescribed dosage.
Hope I have answered your query.