generate/generatetoaddress what are this two rpc methods used for? can anyone explain what are this rpc methods used for:
1.generate
https://bitcoincore.org/en/doc/0.16.3/rpc/generating/generate/
from the introduction of generate mehod: 


  Mine up to nblocks blocks immediately


but how? bitcoin is hard to mine, how can this method mine nblocks immediately?

generate nblocks ( maxtries )

Mine up to nblocks blocks immediately (before the RPC call returns) to an address in the wallet.

Arguments:
1. nblocks      (numeric, required) How many blocks are generated immediately.
2. maxtries     (numeric, optional) How many iterations to try (default = 1000000).

Result:
[ blockhashes ]     (array) hashes of blocks generated

Examples:

Generate 11 blocks
&gt; bitcoin-cli generate 11


2.generatetoaddress
https://bitcoincore.org/en/doc/0.16.3/rpc/generating/generatetoaddress/

the same question as generate method

generatetoaddress nblocks address (maxtries)

Mine blocks immediately to a specified address (before the RPC call returns)

Arguments:
1. nblocks      (numeric, required) How many blocks are generated immediately.
2. address      (string, required) The address to send the newly generated bitcoin to.
3. maxtries     (numeric, optional) How many iterations to try (default = 1000000).

Result:
[ blockhashes ]     (array) hashes of blocks generated

Examples:

Generate 11 blocks to myaddress
&gt; bitcoin-cli generatetoaddress 11 "myaddress"
but how? bitcoin is hard to mine, how can this method mine nblocks immediately?


generate is only used on the regtest network, where blocks can be mined instantly.