Electrical bistability in molecular films: transition from memory to threshold switching