We consider scheduling a batch of jobs with stochastic processing times on single or parallel machines, with the objective of minimizing the expected holding costs. Preemption of jobs is allowed, and the holding costs of preempted jobs may depend on the stage of completion. We provide a new proof of the optimality of a Gittins priority rule for the single machine and use the same proof to show that the Gittins priority rule is nearly optimal for parallel machines.