An electric fence is a security barrier that uses electric shocks to deter animals or intruders from crossing a boundary. It consists of wires that carry an electric current and are mounted on insulators along a fence line. When an animal or person comes into contact with the electric fence, they receive a painful but non-lethal electric shock, which typically serves as a strong deterrent.