It depends on how comfortable I feel with the person and whether I'm switched "on" or "off" socially.
When I'm in "on" mode (which is still pretty shy and insular compared to most people) I'll happily speak (or just say hi, if one of us is busy) to people I both know fairly well and like, of course. I find it a little awkward to run into people I either don't know very well or dislike, but I'll say a brief hello to avoid even more severe awkwardness.
When I'm in "off" mode I get this irrational, anxious feeling of not being "prepared" to have unexpected interactions with others, and I feel a little jolt of panic when I unexpectedly see someone I know before immediately trying to get out of their line of sight. Maybe I'm performing to some degree during most interactions with others (e9-ish self-hiding/extreme accommodation and 3w4/4w3-ish portrayal of an image to others) and sometimes I just want to feel completely free from that. It's common for me to feel like I need a notice in advance if I'm going to be socializing; I've even gotten supremely annoyed at friends who have come to my door without calling first. When I was very unhealthy I was switched Off much of the time -- now I'm probably closer to an average level of health and manage to be switched On most of the time in public.