Using a lot of threads

Discussion in 'Plugin Development' started by Baba43, Jun 26, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Baba43

    Hey, I want to delay the teleportation of players in my teleport plugin. For me it would be simple to create a new delayed task for each user but I'm coding for a huge with usually more than 100 players online so I really dislike the idea to "spam" new tasks.

    Can you tell me if this doubts are sustainable?

    The alternative for me would be to have ONE task that is counting integers up every second until they reached the specific time.
     
  2. dont use new threads, use the scy tasks from the schedular instead(no thats not called thread)you can do the alternative, that sound the best for me
     
  3. Offline

    Dreeass

    So if I understand correctly, then you want to create a plugin to make a teleport delay on the plugin you already have. I'm not sure but maybe there is a PlayerTeleportEvent that you can use.
     
  4. Offline

    Baba43

    And then? I still have to delay the teleport :D
     
  5. Well, you say there wil be alot of players expected... but will they all teleport frequently ? You can just make a task for each player in that case instead of making a constant task... which Bukkit already has to trigger the tasks plugins create :}
     
  6. Offline

    Dreeass

    Well just do a delayed task on the event and get the amount of seconds from the config.
     
  7. Offline

    Baba43

    I know that possibility the question was if it would be better to do the alternative because otherwise I make bukkit creating 100000 threads until the next restart.
     
  8. Offline

    wirher

    When thread is done it is being deleted from scheduler. Where's your problem? You can make it in one thread by using relative time with players in hashmap and use loop for checking if time-when-tp < System.currenttimemillis() but I don't think if it would be more effective thank separate tasks.
     
Thread Status:
Not open for further replies.

Share This Page