Random namely :java.util.Random,

ThreadLocalRandom namely :java.util.concurrent.ThreadLocalRandom
SecureRandom namely :java.security.SecureRandom

Q:Random Is it thread safe ?
A:Random It's thread safe , But the performance may be low under multithreading .
Reference resources :
http://docs.oracle.com/javase/7/docs/api/java/util/Random.html
http://stackoverflow.com/questions/5819638/is-random-class-thread-safe

Q:ThreadLocalRandom Why so soon? ?
A: In fact, this look at the source code to know .. because Random Used a lot of CAS Class ,ThreadLocalRandom It's not used at all .

Q: Why in the case of high intensity requirements , Do not use Random?
A: Especially in the case of generating captcha , Do not use Random, Because it's linearly predictable . I remember a news story about a XX Website , To show its fairness , Open its source code , As a result, the random number predictable vulnerability was attacked . So in the situation of high security requirements , Should be used SecureRandom.
Reference resources :http://www.inbreak.net/archives/349

Q: Theoretically, random numbers generated by computers are pseudo-random numbers , So how to generate high-intensity random numbers ?
A: Generate high-intensity random numbers , There are two important factors : Seeds and algorithms . Of course, there are many algorithms , But how to choose the seeds is a key factor . Such as Random, Its seed is System.currentTimeMillis(), So its random numbers are predictable . So how to get an approximately random seed ? Here's a very unique idea : Collect all kinds of computer information , Such as keyboard input time ,CPU The clock , Memory usage , Hard disk free space ,IO Time delay , Number of processes , Number of threads and so on , To get an almost random seed . In this case , In addition to the possibility of cracking in theory , In fact, there is no possibility of being cracked . As a matter of fact , Today's high-strength random number generators are implemented in this way .
such as Windows The random number generator under :
http://blogs.msdn.com/b/michael_howard/archive/2005/01/14/353379.aspx
http://msdn.microsoft.com/en-us/library/aa379942%28VS.85%29.aspx
Linux Under the /dev/random:
http://zh.wikipedia.org/wiki//dev/random
According to the SecureRandom Of Java doc, Speaking of in class unix Under the system , It could be using /dev/random, To achieve .

Other interesting things :
The fastest security required generation UUID Methods ( Be careful , The intensity is not high , It's possible to repeat ):

[java]  view plain copy

 
  1. new UUID(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong());  

On a website , Forget the source .

Randomly generated functions that generate random numbers ?
Whether a random number generator can be used to generate a series of random code , And then as a new random number generator ? It seems that strength is transmitted , It doesn't seem to make sense .

from :http://blog.csdn.net/hengyunabc/article/details/9913143

[ turn ]Java The random number generator in :Random,ThreadLocalRandom,SecureRandom More articles about

  1. Java The random number generator in :Random,ThreadLocalRandom,SecureRandom

    Java The random number generator in :Random,ThreadLocalRandom,SecureRandom In this paper, the Random namely :java.util.Random,ThreadLocalRandom namely : ...

  2. Java The random number generator in :Random,ThreadLocalRandom,SecureRandom( turn )

    In this paper, the Random namely :java.util.Random,ThreadLocalRandom namely :java.util.concurrent.ThreadLocalRandomSecureRandom namely ...

  3. Java Two methods of generating random numbers in

    Java Two methods of generating random numbers in One . utilize random Method to generate Java random number . stay Java It's generated in language Java Random numbers are relatively simple , Because there's a ready-made way to use . stay Math Class ,Java Language provides a ...

  4. Why do you say Java All random numbers in are pseudo-random numbers ?

    What is pseudorandom number ?  1. Pseudo random number is a periodic sequence which seems to be random in nature , That is to say, random with rules . 2. As long as the random number is generated by the deterministic algorithm , That's pseudorandom , It can only be optimized by continuous algorithm , Make your random number closer to random .   ( Random this ...

  5. Java Guess boxing game using random numbers in

    Java Guess boxing game using random numbers in , Implementation is very simple , The difficulty lies in the generation of random numbers . First GameJude Class is a class that is used to judge the winning or losing : package testGame; public class GameJudge ...

  6. java The random number in Random

    java In general, there are two kinds of random numbers , One is Math in random() Method , One is Random class . One .Math.random()  :      Generated immediately 0<x<1 Decimals of example : How to write , Generation random generation ...

  7. java in random The use of several methods Math.random() and random().

    random java Sometimes we need to use random To generate random numbers , Let me give you a brief introduction java in random How to use The first one is :Math.random() public static doub ...

  8. Java The generation method and principle of random number in

    Look up the information about random numbers , It's a special arrangement First of all java There are several ways to generate random numbers in stay j2se We can use Math.random() Method to generate a random number , The resulting random number is 0-1 One between double, We can ...

  9. Tools section -Java Some of them utils

    Below are some of the finishing Java Developed utils, By the way, the editor make complaints about Sina blog bad , So switch to blog Garden One . character string 1. Java in String Conversions with other types String And date objects pu ...

Random recommendation

  1. WPF How to achieve a similar 360 Security guard interface program ?( Shared source code !)

    Previous studies Windows Form When programming , I always feel that my interface is ugly , notice 360 Safety guard . Thunderbolt and other software UI The designs are very beautiful , My heart is always looking forward to if I can achieve this UI How good the effect should be !!! Another problem that bothers me is , This ...

  2. web Big file upload control -jsp-oracle-bug Repair -Xproer.HttpUploader6

    explain : Fix delete folder logic error   1. to update up6.js Before updating : After the update : Code :         , "RemoveFolder": function (fileSvr) ...

  3. iOS Of UIWindow Class research

    Today I found that if you want to make a beautiful interface effect , We need to study it carefully UIWindow This class . It's not clear why there is such a UIWindow class , It goes with UIView What is the fundamental difference between ? and Android What is more similar in . To do first ...

  4. NBUT 1010 Magic girl (DP)

    [1010] Magic girl The time limit : 1000 ms Memory limit : 65535 K Problem description Some time ago, Xu yuanxuan's great offering and small circle really caught fire . In the black long straight ( Xiaoyan ) Climbing up the stairs to fight against the witch's night , She has a problem and wants to ask for your help . ...

  5. python Realize single chain table

    #! /usr/bin/env python ### ### Linked List python implementation ### ### @reference Data Structures ...

  6. cxf call c# Of webservice

    java call c# Of webservice, Now it has passed the test . And used in the project . Now I'd like to share with you the implementation method and the problems encountered . Detailed source code, such as the following : JaxWsDynamicClientFactory dcf = ...

  7. PHP Regular expression questions

    1.POSIX Regular expressions extend in PHP Which version was abandoned 2. Please write any number that matches , Any white space character , The symbol of any word character ? 3. What is the function that performs a regular expression match ? What are the returned results ? 4. Execute a global regular expression ...

  8. Yarn A little understanding

    Text Open the website http://hadoop.apache.org/docs/r2.6.5/hadoop-yarn/hadoop-yarn-site/YARN.html, Bring me the picture . I use it 2.6.5 ...

  9. Main stream nosql Database comparison

    Currently open source NOSQL The database has ,Redis,Tokyo Cabinet,Cassandra,Voldemort,MongoDB,Dynomite,HBase,CouchDB,Hypertable, Ri ...

  10. win10 Use... In the environment pyinstaller hold python Code (.py) Package as executable (.exe)

    Preface Recently, I wrote a small test program ,python It only takes a hundred lines to write , But when it's packed, there's no C So easy . Here is a record of my difficult " pack " The process . Method 1 :py2exe py2exe It's a classic ...