How does a Semiconductor Work?

Semiconductor sometimes work as conductor & sometimes insulator. It works as per energy given to electrons in it. If they gain enough energy, they cross the barrier.