Assuming you turn the compost regularly, it's an aerobic process. However, if you build the heap too high, and/or it gets too wet, and/or you don't turn it often enough, it can go anaerobic. I believe that's unlikely to happen on a homeowner scale, and presumably at municipal scale they'll have industrial infrastructure to turn it regularly until it has finished decomposing.