Skip to content

replace busy wait loop with Thread.sleep in WaitUtil#501

Merged
frankgiordano merged 2 commits into
zowe:mainfrom
chaitanyakatore:optimize-wait-utility
May 29, 2026
Merged

replace busy wait loop with Thread.sleep in WaitUtil#501
frankgiordano merged 2 commits into
zowe:mainfrom
chaitanyakatore:optimize-wait-utility

Conversation

@chaitanyakatore
Copy link
Copy Markdown
Contributor

@chaitanyakatore chaitanyakatore commented May 25, 2026

Description

This PR optimizes the WaitUtil.wait helper by replacing an inefficient CPU busy-wait loop with Thread.sleep(). It also cleans up the codebase by removing the unused Timer class and introduces unit tests for WaitUtil.

Changes Made

  • Wait Optimization: Modified WaitUtil.java to use Thread.sleep() and handle the InterruptedException internally. This frees up the CPU during wait operations (used by JobMonitor and UssCmd).
  • Code Cleanup (Deleted Unused Classes): Deleted Timer.java and TimerTest.java since the Timer class is no longer utilized anywhere in the codebase.
  • Added Unit Test: Created WaitUtilTest.java under src/test/java/zowe/client/sdk/utility/timer/ to test wait-duration blocking and validate utility class structure (author set to Chaitanya Katore).
  • Documentation: Updated the Javadoc in package-info.java to reflect the removal of the Timer class.

Verification

  • Ran ./mvnw test to execute the full test suite.
    • Result: BUILD SUCCESS
    • Tests run: 788 (reflecting the removal of TimerTest and addition of WaitUtilTest), Failures: 0, Errors: 0, Skipped: 0

Comment thread src/main/java/zowe/client/sdk/utility/timer/WaitUtil.java
* @author Frank Giordano
* @version 6.0
*/
public class TimerTest {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should delete timer class which makes this class unnecessary.

/**
* Class containing unit tests for WaitUtil.
*
* @author Frank Giordano
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use your name.

…utilization during wait times

Signed-off-by: chaitanya <chaitanyakatore@gmail.com>
@chaitanyakatore chaitanyakatore force-pushed the optimize-wait-utility branch from 5971189 to 1f2718a Compare May 26, 2026 17:25
@frankgiordano frankgiordano merged commit 1fef378 into zowe:main May 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants