Hi Zaphod1, master of the Universe.
I have used pressure air and a pressure switch for that purpose. Use a tube with almost same diameter as hole. Tube is closed at the end. Make a hole on the side of the tube. Apply pressure through adjustable valve and measure pressure in tube. You will get three different readings; one very low when tube is out of hole, one rather high when tube is down unthreaded hole and one in-between when tube is down threaded hole.
A pressure-to-volt transducer will give you an electric signal and a comparator with adjustable threshold will produce an ON/OFF signal that tells you if you have a thread in the hole or not.
Regarding programmability; you could probably use different sleeves that you slide onto the probe, put them just upside the hole in the side. Adjust threshold for each diameter you have.