Well, the usual suspects are LocTite -- any hardware store. Devcon
makes one as well. Threads need to be clean, etc., for it to work
Back when I was in the electronics game, we used to use a dab of red
nail polish. Cheap stuff in the local drug store.
Urethane varnish might do as well. I do a fair amount of model ship
building, and I find a drop of varnish (ready at hand!) works nicely
for anchoring things.
The problem is when you need to loosen things up again. For example
the "red" LocTite needs some heat.
Peening the threads a little, as the other poster suggests would work,
but that sort of goes against my grain.