MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.21k stars 21.37k forks source link

Why do the Java code samples create a CountDownLatch, but never call await()? #120264

Closed TKProlifics closed 6 months ago

TKProlifics commented 7 months ago

[Enter feedback here]

I am writing a JMS client that runs in a Function App. It will run every 15s and continue to get messages from a queue until the queue is empty (even if it takes more than 15s). The messages get transferred onto a Service Bus queue.

I am very puzzled by the use of CountDownLatch in the code samples on this page. I have read the Java docs. Based on the docs, there is no point in creating a CountDownLatch unless there is a call to its await() method somewhere. But none of the code on this page calls await()!

Is this redundant code, or am I missing something important?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

RamanathanChinnappan-MSFT commented 6 months ago

@TKProlifics Thanks for your feedback! We will investigate and update as appropriate.

MayankBargali-MSFT commented 6 months ago

spelluru Can you please review it. It looks like the sample code can be modified to remove the CountDownLatch and still achieve the same result. Let me know in case I have missed anything.

spelluru commented 6 months ago

@MayankBargali-MSFT - Yes. It's not needed. I will update and publish the article today. Thanks.

spelluru commented 6 months ago

The update is live now.

please-close