Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 코드 리뷰 테스트 #31

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/woowa/team4/bff/review/ReviewThis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package woowa.team4.bff.review;

public class ReviewThis {

private static int value = 0;
private static boolean flag = false;

public static void main(String[] args) {
new Thread(() -> {
while (!flag) {
Copy link

Choose a reason for hiding this comment

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

r: while (!flag) 루프는 무한 루프가 될 수 있으며, flag가 변경될 때까지 대기하는 것은 비효율적입니다. flag가 변경될 때까지 대기하는 방법을 개선해야 합니다.

}
System.out.println("value: " + value);
Copy link

Choose a reason for hiding this comment

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

c: System.out.println 대신 로깅 프레임워크를 사용하는 것이 좋습니다. 이는 코드의 유지보수성을 높이고, 로그 레벨을 조정할 수 있는 장점이 있습니다.

}).start();

new Thread(() -> {
value = 42;
Copy link

Choose a reason for hiding this comment

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

c: valueflag의 접근을 동기화해야 합니다. 현재 상태에서는 멀티스레드 환경에서 데이터 일관성이 보장되지 않습니다.

flag = true;
}).start();
}
}
Loading