Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Dec 7, 2024

What problem does this PR solve?

This PR addresses the issue of busy-waiting in the session expiration task of the Server Session Pattern. Previously, the session expiration thread continuously checked for expired sessions without any pauses, which led to unnecessary CPU consumption.

Key improvements:
Replaced the busy-waiting loop with a Thread.sleep() mechanism, ensuring the thread pauses and consumes no CPU resources between checks.
Added graceful handling of thread interruptions for proper thread lifecycle management.

This change significantly reduces the overhead caused by constantly checking for session expiration, making the session management more efficient and resource-friendly.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2024

@ghost ghost changed the title Update README.md fixing-busy waiting loop #server session Dec 7, 2024
@iluwatar
Copy link
Owner

Changing the README.md file doesn't fix the code because the README.md file is a documentation file, not the code itself.

@iluwatar iluwatar closed this Dec 16, 2024
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