New Threads and URL connection highscores

I am not sure where this exactly goes.

I have my game, at the end of the round(aka you died)

I want it to submit a highscore. I got this working. I got my game working

However, because once you die, animations and other stuff(the bad guys/explosions) continue to play. The connection/submission of the score code causes some stutter for a second or 2 at most.

So I wanted to somehow make the score submission run in parallel or separate. So I made a new Thread(new Runnable){//submitScore()}}.start();

This works perfectly fine. It removed all stutter and issues. However, do I need to stop/close this new thread at all or once it completed it tasks it does it do it automatically?
(also, I do have the httpURLconnections disconnect when I am done while inside this new Thread, that’s the only thing I could find to shut off/stop/disconnect)

secondly, I was researching about it and although I am not using JEE, they say its discouraged there. Should I be concerned with it being discouraged somewhere else? Any suggestions on improvements? or is there nothing wrong with doing this?

As soon as the run method returns, the thread stop.

And what is discouraged? Where does it say that it is discouraged?

They’re probably talking about from the server’s perspective. The debate of spawning a new Thread for each new client vs NIO. Being that you’re not a server, you can safely ignore that whole debate.

It’s discouraged to stop Threads explicitly. If you have reasons, it’s okay to use a thread-per-client design.
As for the OP, you should be safe :slight_smile: