Although I've never used one, I believe that they actually give a little warning shock when the dog gets within a certain distance of the fence line, then a full shock if they cross the line.
A neighbor of ours had one, and I do know that his dog never, ever left that yard.

I would imagine that I would learn pretty quick not to cross a certain bounday if I got zapped every time I got near it.
It won't keep other animals from coming into your yard though.