In reality on a very small scale, the molecules of a gas or a liquid wil never have the same energy, some wil go faster than others, why this is you can see here.
If you where able to sort them out, you end up with a temperature difference, then it would be possible to convert it into a other form of energy.
The nineteenth century scientist Maxwell imagined that a little demon could be able to do the trick.
Go to the Maxwell's demon page for more info.
On this very small scale there is the effect called Brownian motion, small particles moves randomly because they are hit by the molecules of the gas or liquid where they are suspended in.
It would be a violation of the Second law if the weren't moving at random, this is the subject of the Brownian motion page go there to learn more.
A other possibility is this, in a vacuum you have only exchange of heat by radiation, al objects send out en receive radiation, when al objects have the same temperature the send out the same amount as the receive, if you could chance this you might get temperature differences for free, check out the Heat radiation page over this.
All the java applets are from NTNU Virtual Physics Laboratory, go there for more nice Applets.