Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

Conversation

minsu11
Copy link
Contributor

@minsu11 minsu11 commented Nov 6, 2023

No description provided.

public void run() {
getBuyItem();
mart.enterStore(buyItem);
while (!isCheck.get()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wait으로 기다리는데

while (!isCheck.get()) {

이 있어야 할까용

mart.exitStore(buyItem);
}

public void getBuyItem() {
Copy link
Contributor

Choose a reason for hiding this comment

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

여기에서만 사용한다면 private 접근 제어자를 사용하거나 랜덤한 값을 리턴하는 메서드면 더 좋겠습니다

thread.interrupt();
}

public void join() throws InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

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

사용하지 않는 메서드들은 지워줘도 좋을 것 같습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

추후에 사용할 수 있기 때문에 join을 만들었습니다!

@@ -0,0 +1,15 @@
package com.nhnacademy.parkminsu.assignment;

public enum Items {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 enum은 사용처가 없습니다
지우거나 활용하면 좋은 코드가 될 것 같습니다

Copy link
Member

Choose a reason for hiding this comment

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

맞네요 enum을 구현했는데 활용을 하지 않았네요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다

Thread.sleep(ThreadLocalRandom.current().nextInt(1000, 10000));
store.sell();
System.out.println(thread.getName() + "가 구매했습니다");
isCheck.set(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

이런 흐름이라면 isCehck가 필요 없을 것 같습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다!

* 매장에서 물건이 들어오면 소비자에게 알려줌
*/
public class Store {
AtomicInteger consumerCount;
Copy link
Member

Choose a reason for hiding this comment

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

접근제어자가 필요할 것 같습니다



public Consumer(String name, Store store) {
thread = new Thread(this, name);
Copy link
Member

Choose a reason for hiding this comment

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

여기만 this 키워드를 안써준 이유가 있을까요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다!

@@ -0,0 +1,15 @@
package com.nhnacademy.parkminsu.assignment;

public enum Items {
Copy link
Member

Choose a reason for hiding this comment

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

맞네요 enum을 구현했는데 활용을 하지 않았네요

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants