If you really want to stay up-to-date with the latest firmware updates, but don’t want to lose your jailbreak, then your in luck! (If you have an old bootrom iPhone 3GS that is.) There isn’t any reason to update to 4.0.2 since it only patches the PDF exploit, and Saurik has already taken care of that.
Nevertheless, the latest PwnageTool is able to jailbreak the 3GS by rolling a custom .ispw, which is nowhere as convenient as using Jailbreakme, but it will get the job done.
Hit the source for the full how-to.