ZHENGZHOU, China—Early one day last week, a 31-year-old man finished his night shift on an iPhone assembly line, climbed to the top floor of Foxconn Technology Group ’s L03 production building and leapt to his death. He had been on the job for a month.

The next day, Aug. 19, another Foxconn worker was struck by a train and killed. Driving rain had flooded pedestrian underpasses, and she had scaled a fence to cross the railway tracks in an attempt to get to work.

The two deaths in the northern Chinese city of Zhengzhou—where Foxconn runs Apple Inc.’s main site for iPhone production—came under completely different circumstances. But to the tens of thousands of workers who have joined the factory ranks in recent weeks to assemble Apple’s next-generation iPhone, the deaths are a reminder of the stresses and hazards that can come with the factory jobs promoted to poor Chinese here and in other manufacturing centers as a ticket to the middle class.

“Why is it always the entry-level workers who jump?” asked one Foxconn employee. The suicides that occur at the Foxconn factory from time to time, she said, reflect the precarious existence of Chinese migrant workers and their lack of money and resources to solve personal problems.

Foxconn expressed its condolences for the death of the worker at its building and said it was cooperating with an investigation into the circumstances.