Z
Zachary P. Landau
I have a few classes that all try to obtain the same data as each
other using different methods. Each one takes around 5 seconds to get
the data, so I'd much rather have them all try to get it at once. I
only need the data once, from whoever gets it first.
So what I would like to do is have, lets say, fetchdata() for each
class called in a thread, and as soon as the first non-nil is returned
from fetchdata, I want to kill the other threads and go on with the
program.
I have read the threading documentation and tried to play around a bit
with it, but I can't seem to get it to do what I want. If someone
could tell me how to do it or give me a point in the right direction,
that'd be helpful.
other using different methods. Each one takes around 5 seconds to get
the data, so I'd much rather have them all try to get it at once. I
only need the data once, from whoever gets it first.
So what I would like to do is have, lets say, fetchdata() for each
class called in a thread, and as soon as the first non-nil is returned
from fetchdata, I want to kill the other threads and go on with the
program.
I have read the threading documentation and tried to play around a bit
with it, but I can't seem to get it to do what I want. If someone
could tell me how to do it or give me a point in the right direction,
that'd be helpful.