1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Creating a new Thread

Discussion in 'Development' started by Sandertv, Jan 26, 2017.

  1. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Hello!
    I've been thinking it could be good for a plugin of mine to start a new thread, but even after reading some threads on the old forums, I haven't found a clear way to make a thread and how to do some things. Can someone explain to me in detail how to make a new thread and how to manage it?

    Thanks in advance!
     
    Muqsit, InspectorGadget and gistrec like this.
  2. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    Anyone got an answer to this? I'm interested as well and this seems like a pretty valid question.
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    First off:
    Do you really need a thread? What do you want to use the thread for?
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Well first, I just like to have a lot of knowledge about it. :p Even if it's not a smart idea, it's good to know how it works.
    Second, I'm planning to use a new thread for settings blocks. Repeating tasks do not work efficiently for a plugin I'm working on, and as far as I know (and read) I think it's not a good idea to schedule async tasks a lot of times consecutively in a short time.
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    setting blocks? you know that that is not possible. And scheduling AsyncTasks barely has much more overhead than creating a new thread.
     
  6. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Saying something is not possible does not help. If you're so sure it is not possible, please explain me why it is not. That's what I made this thread for after all. I don't really care if something is possible or not, only what you can do with making a new thread.
     
  7. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    You can change chunk in AsyncTasks and on completion set this chunk to server :)
    I use this method, when use world edit (create big sphere (with radius 100 or more))
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Maybe you should learn what a thread is. There is enough on the internet.
    Did you read some docs? Ok, then you may already know why you can't set blocks from there. If not:
    The main thread is doing its things and handling levels. You are now in another thread and want to make setBlock calls. The main thread would have to be interrupted and do that. It would simply result in the same.

    yes, that will be a bit faster
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.