java - Need Help And Ideas In Solving A Collection Problem -


I have already posted a question. This question is about the same project, but unrelated. I am developing an application for Lego NXT Mindstorm Robot. I have a GUI running on two robots and PCs.

In Lejos NXJ you can only use one input reader. This means that you can not connect the PC directly to two robots and allow two robots to connect directly to each other. So that's what I did. I have connected the PC directly to two robots and when I want to contact two robots directly, I send my message through a GUI.

There is a lot of communication between the GUIs and robots. Well, between the robots, I write the data in the output stream at any time due to this reason. It seems that some data overwrite by others Is done and the system is not working properly.

I have been advised to write a class that holds a collection (queue) object so that whenever the robot wants to send something, it adds it to the collection (queue) and from that class which catches the collection object There will be a method so that it sees the collection continuously and whenever it is not empty, it sends the data into the output stream in the archive.

This means that whenever the data is sent to the output stream in the archive, it is possible that new data can be added.

Some people suggested using ARLokQuee and etc. to me. But those classes are not available in the class.jar file which uses robots.

The collection squares I know in this jar file are vector and qi.

I am asking that someone can help me by telling me how to think about how such classes One method in the classroom will check periodically if there is data inside the archive and it will send them through the output stream. When it is sending, it is possible that new elements are being added.

Since the data is being sent from one place, no data will overwrite the other.

Thank you.

vector is good because (at least in Java SEO - I do not know how to use Mindstorm It is synchronized, so all calls are atoms - if you try to add something to another thread vector when you

Alternatively, you may want to take a look at Collections Class.

Alternatively, you can do your own implementation of the blocked queue by subclassing a standard line, though more complex, a blocking queue is a better solution, because it avoids a busy wait You frequently check the queue and every time it is said empty.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -