I think the first two ranks could throw them, but the two ranks would need to space themselves out, the first rank moving further forward before throwing than the second. Javelins were aimed upward so that they didn't fly past the heads of the men in the rank ahead. And I don't think the two ranks 'pulled back' after moving forward to throw their missiles - they stayed where they were to receive the enemy charge.