A specialized machine, known as a filling machine, pushes the bristles into holes in the head of the handle and then staples them into place. Another toothbrush machine, a trimming machine, trims off the ends of the nylon bristles so that they are all the proper length. In toothbrushes with specialized bristles, this machine will also trim the bristles at the correct angle.
High speed toothbrush machine: