If you follow one of the modern patterns (MVC, MVVM etc) your GUI should be separated from your business logic such that you can test the latter even before the GUI is designed. So work on the business side of things first, it's much easier to add or modify the GUI than to rework your classes to match the display.
It's generally not good practice to have public variables, as such. Pass them as parameters or use setters and getters[^].
Thanks for your reply, I'll study about the two patterns you suggested me.
For public variables, I show my problem:
I want to write data on RS232 port, wait a reply, read data arrived and elaborate them. I create a SerialPort object using RxTx libraries and I setted a Listener to it. In my main class, a method write the data on the serial port and then wait on a Condition variable. The listener have to notify to the waiting method the arrival of the data. The two methods are on completely different classes, so I thought to make the condition variable global. Unfortunately, at now the program doesn't work. What shall be the right way to do solve kind of problem?
Unfortunately, at now the program doesn't work. What shall be the right way to do solve kind of problem?
Sorry, but that information does not help us to understand what is happening. I suggest you open a new question, and show the part of your program that does not work, and explain exactly what errors you are seeing. Don't forget to add <pre> tags (use the code button above the edit window) around your code so it is readable like:
sure I checked the documentation very well, and I am sure from the port number and IP address are correct! I mean BY "it does not executed with me" It can not read from the device, just connect and wait for response from the device without hope to retrieve the data I do not know where is the error in my code !!
Well you need to use your debugger to check what is happening internally. But, more importantly, you need to be sure that the device is functioning correctly, and communicating with your PC. And for that you need to contact the device manufacturer for help.
Forget what is not mentioned and focus on what is. You cannot create an application to use this device by guesswork, you need to study the documentation and follow what is says. If the documentation is not clear then go back to the manufacturers and ask for help.
Is there any way to call public method of a child thread from its parent class
Yes but I am guessing that you really do not want to do that.
Typically different threads do not communicate except very explicitly. Note that I said "thread" not class. If you want a thread to communicate with another thread then you first figure out what the best way to do that is and THEN you figure out which classes will do it (and how.)