There's a lot of things that get checked when you take the car in for a brake inspection. The thickness of the linings is just the start. If you have wear indicators, those will squeal long before the linings wear down too far. If the linings are worn enough to allow the rivets to grind on the rotors, you will still see some lining left. Also be sure to inspect the entire linings from end to end. They commonly wear unevenly and one end can still look okay.
Dust and dirt become embedded in the linings over time and can cause a squeal. Glazed linings can do that too. Usually all that's needed for that is to have a light cut taken on both sides of the rotors. Most auto parts stores will machine them for you as long as they will still be above the published minimum legal thickness.
You may have to do the same prep work to the pads that we do when installing new ones. Run a flat file over the pistons and calipers to insure there's no high points from dirt or rust. Coat those contact points with high-temperature brake grease too. The pads must sit squarely on the contact points to reduce their tendency to vibrate, and they must be lubed to allow them to vibrate freely without transmitting that squeal to the calipers where it would be amplified.
Cut the sharp corner on the leading edges of the pads to reduce the "fingernails-on-the-blackboard" effect. A few passes with a flat file is sufficient.
Most importantly there must be no grease of any kind on the rotors or linings. That will definitely cause a squeal. Even fingerprint grease must be washed off.
Don't overlook the possibility of broken hardware on the calipers. Anti-rattle springs and pad separators are used in many applications. They can rust apart or loose their tension and rub on the rotor.