Mechanism of threshold switching in semiconducting glasses