Multiple threads are indeed the recommended way of doing what you want. Do
not confuse that with having multiple *IOIOThreads*, which is *not* what
you want.
A thread is automatically created by the IOIO framework for every possible
IOIO connection. This is some internal bookkeeping that is not immediately
relevant for you, but in short, this will be the thread on which your
setup() / loop() / disconnected() methods will run, should a session to the
IOIO be established on that particular possible connection. The deprecated
stuff is indeed, er, deprecated and I would strongly recommend that you
don't use it.
>From the setup() method (which is called once you have a live IOIO session)
you can do whatever you want. Specifically, you can create multiple Threads
(just normal Java threads), passing them the IOIO instance of some more
specific interfaces or whatever and do real work. The IOIO API is
completely thread-safe, you don't need to worry about synchronizing access
yourself.
For clean closing, make sure that all these threads exit quickly after the
IOIO connection drops (e.g. in response to ConnectionLostException), and
that your disconnect() method join()s all threads, i.e. waits for them to
exit.
That's pretty much it. The IOIO codebase contains an app called IOIOTorture
test which uses a similar pattern. In that case, it is exercising all the
peripherals concurrently to validate the IOIO software / firmware under
concurrent load.

On Sun, Apr 5, 2015 at 7:34 PM, Shantanu Gore <[email protected]>
wrote:

> Hey everyone,
>
> I would like to spawn multiple IOIO threads, one for each
> motor+potentiometer pair I have. I have been looking for how to do this for
> a few days now, but everything I find seems to be outdated (using the
> deprecated method AbstractIOIOActivity).
>
> Basically, I would like to be able to move each motor simultaneously,
> concurrently, and independently. The best way that I can think of to do
> this is through separate threads for each motor+pot pair, rather than an
> event loop like many of the examples I am able to find seem to be doing.
>
> Is there a reason why BaseIOIOLooper seems to be replacing IOIOThread, or
> am I missing something?
>
> Thanks in advance for your help!
>
> Shantanu
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to