In modern Russian, прикол is a very frequently used word and means a joke, a funny incident, or just anything funny, but the original meaning of this word is very different: a stake to which a ship, a tent, or an animal is tied. At least, only such a definition is given in Dictionary of Church Slavonic and Russian composed by the Second Department of the Imperial Academy of Sciences, published in 1847. Russians still occasionally use this word in its original meaning, e.g., in the idiomatic phrase корабль стоит на приколе (the ship is laid up). The composition of this word is very simple: кол is the root of the word, means a stake, and is related to the verb колоть (to pierce, stub, or cut), and при is a prefix similar to the English prefix in, so the composition of прикол contains nothing related to joking, which means that the modern meaning is figurative or derived.
My question: How did прикол, originally meaning a stake, came to mean a joke? In other words, what is the logical connection between the modern and original meanings of прикол?
I did some research on the Internet and saw a hypothesis that the modern meaning stems from a criminal jargon, but it is unclear as to exactly how Russian criminals saw a connection between a stake and a joke. Might the connection be that they considered it funny to stab someone with a stake or a knife?