When Hamlet says "to take arms again a sea of troubles" I think he means to end his misery and kill himself. In the next line, he says, "and by a sleep to say we end the heart-ache and the thousand natural shocks that flesh is heir to" Hamlet is surrounded by troubles and heartache and he feels that it would be easier on himself to end it all. Earlier in the play, he says that he would kill himself if it wasn't considered a sin. It seems strange that Hamlet would be talking to himself like this but I think he genuinely didn't know anyone was watching him and that the things he said were true. The thought occurs that Hamlet might think that the ghost of his father isn't really his father but the devil trying to get him to make a mistake by accusing his uncle of murder when he is innocent.
Another though Hamlet mentions in his soliloquy is the thought of the afterlife or hell being worse than his life now. "To grunt and sweat under a weary life, but that the dread of something after death " this is where he is saying that other than the fact that killing yourself is a sin, there is no gaurauntee that the afterlife is any better than the life he is experiencing now. Death is the unknown while his own miserable life is known to him so he decides that he won't kill himself.