Sounds like you have a hermaphrodite caused by stress of your light being to close? Or maybe your light cycle got screwed. Light leaks will also cause this, amoung all the other things you can do to stress your plant.
Yes they can throw male flowers, and reversing the sex is possible.
Hermaphrodism can be triggered by stress but, stress is in no way required. It's just something the plant is capable of and sometimes does even in stress free environments.