But the rest of the dead lived not again until the thousand years were finished. This is the first resurrection.Blessed and holy is he that hath part in the first resurrection: on such the second death hath no power, but they shall be priests of God and of Christ, and shall reign with him a thousand years.
"All that are in the graves shall hear his voice, And shall come forth; they that have done good, unto the resurrection of life; and they that have done evil, unto the resurrection of damnation."( John 5:28, 29.)
In other words,the resurrection of the righteous comes first at the second coming of Jesus, when he returns to take his faithful ones to heaven to enjoy a thousand years of peace before inheriting the earth.
And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also.(John 14:3)
"For the Lord himself shall descend from heaven with a shout, with the voice of the archangel, and with the trump of God: and the dead in Christ shall rise first: Then we which are alive and remain shall be caught up together with them in the clouds, to meet the Lord in the air: and so shall we ever be with the Lord."(Thessalonians 4:16-17)
The second resurrection takes place at the close of the 1,000-year period. The wicked will be raised in this resurrection.
Please make use of the link for a further more detailed study of this important topic.