Lasing threshold and mode competition in chaotic cavities