Threads crashing server...

Discussion in 'Spigot Plugin Development' started by TedTheTechie, Jan 20, 2015.

Thread Status:
Not open for further replies.
  1. Hello! I've been learning Threads recently, and have been stumbling across an issue when using it in MySQL.
    After a short time, the server CRASHES from out of memory errors cause of too many threads ?

    Current way I am using threads:


    Code (Text):
    new Thread() {
        public void cancel()
         {
             interrupt();
          }
            public void run() {
                     while(!isInterrupted()) {
                           //Code executed here

                              cancel(); //Called AFTER all the mysql code
                      }
            }
    }.start()
     
  2. Don't do that please. Use Bukkit's scheduler to create Asynchronous tasks.
     
    • Agree Agree x 1
  3. @PickNChew I was literally changing the code to it and trying it out now.. :p I'll tag you again if it works or not
     
Thread Status:
Not open for further replies.