A) HOW IT WORKS
Usually there are two eight digits codes found for each IMEI number. Try them separately and do not worry with attempting the incorrect one as it will not affect the phone at all. Make sure the phone asks for an unlock code. If the phone is from T-Mobile USA or Metro PCS it might use Device Unlock application and such phone cannot be unlocked by any code.
b) HOW TO USE THE CODE
Power on your device with an active unsupported (not original network SIM) SIM card. Enter one code once prompted. If it does not work enter the second code.