Question: How are random numbers generated.? How do languages such as java etc generate random numbers, especially how it is done for GUIDs.? i found that algorithms like Pseudorandomnumber generator uses initial values. 

But i need to create a random number program, in which a number once occurred should never repeats even if the system is restarted etc. I thought that i need to store the values anywhere so that i can check if the number repeats or not, but it will be too complex when the list goes beyond limits.?

Answer: 
First: If the number is guaranteed to never repeat, it's not very random.

Second: There are lots of [PRNG algorithms](http://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators).

UPDATE:

Third: There's an [IETF RFC for UUIDs](https://www.rfc-editor.org/rfc/rfc4122) (what MS calls GUIDs), but you should recognize that (U|G)UIDs are *not* cryptographically secure, if that is a concern for you.

UPDATE 2:

If you want to actually use something like this in production code (not just for your own edification) **please** use a pre-existing library. This is the sort of code that is almost guaranteed to have subtle bugs in it if you've never done it before (or even if you have).

UPDATE 3:

Here's the [docs for .NET's GUID](http://msdn.microsoft.com/en-us/library/system.guid.aspx)
Specifically regarding Java:

* `java.util.Random` uses a [linear congruential generator](http://en.wikipedia.org/wiki/Linear_congruential_generator), which is [not very good](http://www.alife.co.uk/nonrandom/)
* `java.util.UUID#randomUUID()` uses `java.security.SecureRandom`, an interface for a variety of cryptographically secure RNGs - the default is based on SHA-1, I believe.
* [UUIDs/GUIDs](http://en.wikipedia.org/wiki/UUID) are not necessarily random
* It's easy to find implementations of RNGs on the net that are much better than `java.util.Random`, such as the [Mersenne Twister](http://en.wikipedia.org/wiki/Mersenne_twister) or [multiply-with-carry](http://en.wikipedia.org/wiki/Multiply-with-carry)