EV3 and threading

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Active User
Posts: 147
Joined: Sun Oct 14, 2007 11:21 am

EV3 and threading

Postby ruperty » Sun Jul 13, 2014 1:14 pm

I have an application to run on the EV3 which will continuously access multiple sensors and motors, and I am wondering if I need to consider running different threads for them, rather than my current scheme of accessing them serially. That is, in each iteration I may be reading 3 sensors, reading 4 motors and writing 4 motors, do any of the methods take much significant time to return?

Any thoughts?

User avatar
leJOS Team Member
Posts: 4693
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 and threading

Postby gloomyandy » Sun Jul 13, 2014 3:04 pm

Why not just try it and see? Without knowing what sensor you are trying to use, and what particular motor operations it really is not possible to make any useful comment. Obviously you will need to avoid the blocking versions of the motor calls. I would always do things serially unless you find a problem, people are not good at writing multi-threaded code.

New User
Posts: 14
Joined: Fri Nov 14, 2014 2:16 am

Re: EV3 and threading

Postby wdavies » Fri Dec 12, 2014 12:19 am

Is there a guide to multi-threading in EV3 - it seems to be something that LabView does seamlessly?

I found this for NXT, assume it can't be too different?
http://www.juanantonio.info/docs/2008/J ... EADING.pdf


User avatar
leJOS Team Member
Posts: 4693
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 and threading

Postby gloomyandy » Fri Dec 12, 2014 1:44 am

There is nothing specific to the EV3 about leJOS threads, they are simply Java threads. There are many tutorials out there that describe how to use Java threads. Note however that threads can be very tricky and even very experienced Java programmers often run into problems with them. They are very powerful, but use them with care, many problems can be solved without using threads and if you are new to Java it is probably best to avoid using them until you are more familiar with the language.

User avatar
Advanced Member
Posts: 311
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Re: EV3 and threading

Postby esmetaman » Sat Dec 13, 2014 12:05 pm


Andy has the reason.
It is very important to learn to develop robots with Java if you have more experience with leJOS API and later you use advanced features from the Java Language, for example multi threading.

In the PDF which I wrote some years ago, I showed classic Java Thread Features, but now exist more features to handle "Concurrency problems."
I recommend this book:
Juan Antonio Breña Moral

Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest