|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Multithreading on Java
I understand that there's a Task class in C++, but how do I multithread in Java? I can't find any Java counterpart to the C++ class. Thank you
|
|
#2
|
||||
|
||||
|
Re: Multithreading on Java
|
|
#3
|
|||
|
|||
|
Re: Multithreading on Java
okay thanks, I didn't think to try that because it's not native to the cRIO
|
|
#4
|
|||
|
|||
|
Re: Multithreading on Java
The Command Based programming model available through the WPILib is a good way to achieve concurrency in your software.
http://wpilib.screenstepslive.com/s/...ed-programming |
|
#5
|
||||
|
||||
|
Re: Multithreading on Java
Quote:
Quote:
|
|
#6
|
||||
|
||||
|
Re: Multithreading on Java
the Scheduler when using command based maintains it's own list of active commands, and (when a DS packet arrives) calls their execute() and isFinished() methods for every command on the list (sequentially).
No preemptive scheduling here, everyone's execute() and isFinished() has to play nice.... |
|
#7
|
||||
|
||||
|
Re: Multithreading on Java
Quote:
|
|
#8
|
|||||
|
|||||
|
Re: Multithreading on Java
Each command needs to finish its execute command quickly, any waits or long executions will cause everything else to come to a halt until it is finished.
|
|
#9
|
||||
|
||||
|
Re: Multithreading on Java
Quote:
Please note: this is not veiled criticism of the command based model; I'm just trying to untangle things. |
|
#10
|
|||||
|
|||||
|
Re: Multithreading on Java
Quote:
|
|
#11
|
||||
|
||||
|
Re: Multithreading on Java
Quote:
Let me try re-wording it:
I have no idea if the above description is an accurate account of what the Command Based implementation actually does, but is that what you meant? Quote:
Last edited by Ether : 02-11-2014 at 12:29 PM. |
|
#12
|
||||
|
||||
|
Re: Multithreading on Java
Thank you everyone for the responses. I've been carefully reviewing them all and I think I now have a reasonably coherent idea of how command-based works. There are however a few seeming inconsistencies (or perhaps ambiguities) that I'd like to resolve. Here are two: Firstly, it is necessary but not sufficient that each individual command in the scheduler's queue complete within 20ms. Rather, the sum total of the individual execution times must be less than 20ms. Correct? Secondly, the scheduler maintains not only a queue of all the commands to be run, but also the state of each command... and only the method corresponding to each command's state is executed. Correct? (Compare post 15 to post 17 for example of apparent inconsistency). |
|
#13
|
||||||
|
||||||
|
Re: Multithreading on Java
Quote:
Quote:
|
|
#14
|
|||||
|
|||||
|
Re: Multithreading on Java
Quote:
The second point is also correct. The only real state that the scheduler needs to keep track of is which commands are running for their first time. The only thing I'd like to clarify further is that once a command is finished it is removed from the scheduler. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|