As the comment from Colin Fine
They whistled while they worked
They whistled while they were working
They were whistling while they worked
They were whistling while they were working
are all grammatical and will probably be interpreted as meaning the same thing. The doubled use of the progressive, however, strikes me as not completely natural.
Moreover, if the intended meaning is that they were whistling during the entire time that they were working, none seem to make that thought entirely clear.
In that case, what sounds unambiguous and most idiomatic to me is
For as long as they were working, they whistled.
I see no need to repeat the progressive form with "whistle" because it is already implied by "for as long as." Following that logic, the progressive would be used with the first verb.