This relates more to nerves than muscles. Each nerve has a small artery supplying it with nutrients and oxygen. A good example is the sciatic nerve, which is the largest nerve in the human body and requires a relatively large artery to supply it with blood:
When we sit in a particular way that causes pressure over that nerve, or stand for a long while in a way that stretches the nerve, we effectively reduce or block its blood supply. This may result in temporary loss of signal leading to numbness, weakness or even temporary paralysis. If the pressure on the nerve is prolonged beyond a certain point, there will be irreversible necrosis of the nerve causing permanent nerve damage. An example of this is when a drunk person sleeps on the floor with pressure on the outside of the knee over the "Peroneal Nerve", causing "Peroneal Nerve Palsy" or "Zenker Paralysis".
As for the electric sensation we might feel as a result of nerve damage, the answer is more interesting:
The transmission of signal in the nerves requires variable amounts of energy depending on the type of nerve fibre. Nerve fibres are mainly divided into "Myelinated" and "Demyelinated" ones, with further subdivisions. To put it simply, myelinated nerves have a coating of myeline formed by specialist cells called Schwann cells. Myeline allows the nerve fibre to act as a super conductor to transmit signal faster, but needs more energy to do so compared with demyelinated fibres, which are thiner, slower and more energy efficient.
One of the functions of the super-conducting large fibres is to modulate the pain signal. The damage or loss of these fibres results in "neuropathic pain", which is felt as sharp electric shocks or pins and needles along with many other reported descriptions. This is thought to be the result of the small pain fibres working uncontrolled, leading to the perception of pain without an actual painful stimulus. The super conductors "Myelinated Fibres" are much more vulnerable to injury due to reduced oxygen, while the smaller fibres, some of which conduct pain, are more resilient. This is why we might feel neuropathic pain as a result of reduction in signal rather than due to a painful stimulation. A good example is what happens in an auto-immune disease called Guillain-Barre Syndrome, where the immune cells attack and destroy Schwann cells, leading to significant neuropathic pains as a result of the loss of signal in the corresponding nerve:
Another common example is first degree burns, where the pain continues for a few days following a minor burn due to selective damage of the highly sensitive myelinated fibres leaving the non-myelinated ones intact. Pain improves gradually as the Schwann cells regenerate, improving the signal speed.