This is an excellent article on Shy Bladder which sums up the condition pretty succinctly.
One of the interesting things the article has to say is :
First, familiarity with other people present in the restroom can trigger BBS, with strangers usually (but certainly not always!) leading to greater inhibition than friends or relatives. Because of the personal nature of elimination, the degree of familiarity and perceived acceptance often determine whether or not the paruretic will successfully urinate.
This might help to explain an unexpected success I had a year or two ago.
The bathroom had been empty and I was standing at the urinal trying to go (unsuccessfully) when a friend walked in and took the urinal next to me. I said "Hi" and we struck up a small conversation. Suddenly I was able to go absolutely normally with no self-consciousness at all.
I thought at the time I'd been spontaneously cured but now I understand that I felt accepted and safe in this person's presence and so was able to go.
Further reading :
Shy Bladder article.