We consider a queueing system with multitype customers and flexible (multiskilled) servers that work in parallel. If Qi is the queue length of type i customers, this queue incurs cost at the rate of Ci(Qi), where Ci(·) is increasing and convex. We analyze the system in heavy traffic and show that a very simple generalized cμ-rule minimizes both instantaneous and cumulative queueing costs, asymptotically, over essentially all scheduling disciplines, preemptive or non-preemptive. This rule aims at myopically maximizing the rate of decrease of the instantaneous cost at all times, which translates into the following: when becoming free, server j chooses for service a type i customer such that iϵarg maxiCμi(Qi)μij, where μij is the average service rate of type i customers by server j. An analogous version of the generalized cμ-rule asymptotically minimizes delay costs. To this end, let the cost incurred by a type i customer be an increasing convex function Ci(D) of its sojourn time D. Then, server j always chooses for service a customer for which the value of Ci(D)μij is maximal, where D and i are the customer's sojourn time and type, respectively.