Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
In this example, we have two producers (type 0 and 1) and one consumer. Again, the consumer waits for 50 ms and processes requests from the same type.
I thought it would be easier. The code does not end properly...
Thank you for your reply and your ideas, Tim.
Issues are present when requests arrive around the same time: hence, the slightly delayed processing to properly manage requests.
I do not fully control results of the processed requests so doing a callback on the requester might lead to inconsistency due to unreliable information.
Here is a modified producer consumer example from docs.oracle.com.
The production is going to wait for consumers. Consumers will wait 50ms in the hope to get a bigger production at once. This is a working example which seems to do the job.
Question: Is there a more straightforward way to get production after a waiting time (here 50ms)?
(My solution consists of using two BlockingQueue with different behaviors.)
I tried to help you but I have never used the Scanner class. I need an answer and fast. So I google "Java Scanner how to use it".
Now I get the idea (on a side note, where is the line where the scanner is closed?) and I am confused.
What do you expect from the input? A string made of integers separated by space i.e. "1 -3 5" or directly a list of integers i.e. 1 then -3 then 5?
This expectation has to be clarified in your code.
From your code it seems you expect the user to enter integers one at a time. You tell us it does not work as expected.
Either you use a debugger in a Java IDE or you carefully read your code to imagine what the hell it is doing or you add after line 16:
Long story short: the upgrade of my computer has meant the swap from Oracle JDK to OpenJDk version 15 and Observer/Observable have been declared deprecated!
In the following code (inspired from the last version found in this thread) I just want the rows of the table to be updated.
So, I replace Observer/Observable with PropertyChangeListener/PropertyChangeSupport. It runs as expected.
By curiosity I would like to know how to do it with the use of an interface. Any hint?
On a side note, in class MyRow, m_rank tracks the rank of the row in the ArrayList to avoid looking for it in a loop (see the previous code above). Is there a straightforward way to do it without the use of the explicit member m_rank?
Thank you, Chris, for your help!
1) Ok you are right.
2) I have tried and failed. But now, thanks to you it works . The code follows:
(slightly different from what you described)
Hi,
Here is the code of a kind of client/server communication. It works.
However I am sure there is a better way to notify the client as soon as the message arrives.
Thank you for your help.