Skip to content

Lab2#32

Open
parfen01 wants to merge 16 commits into
Rrenkens:mainfrom
parfen01:Lab2
Open

Lab2#32
parfen01 wants to merge 16 commits into
Rrenkens:mainfrom
parfen01:Lab2

Conversation

@parfen01
Copy link
Copy Markdown
Contributor

No description provided.

@Rrenkens Rrenkens added the invalid This doesn't seem right label Dec 6, 2022
"hobosVillage" : {
"eatingTime" : 10,
"ingredientsCount" : [
11,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Я бы мап сделал, так наугад не совсем понятно.

}

public boolean isWorking() {
return isWorking;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

У нас же тут гонка? Ты вызываешь isWorking из разных потоков, а еще можешь вызвать либо start либо stop.

}
isWorking = false;
for (Thread i : workingThreads) {
if (i.getState() != Thread.State.WAITING) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Тут же не все поджойнились.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Так суть в том, что мы не джойним тех, кто вэйтит, ибо это бесконечное ожидание

"cucumber"
]
},
"Tunnel" : 7,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Тут тоже непонятно, что это за константа.

Comment on lines +45 to +48
if (productsCount.get(product) == 0) {
return false;
}
productsCount.decrementAndGet(product);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Тут все может поменяться:
Пусть у нас 1 еденица товара:

  1. Проверяем на 0, 1 != 0.
  2. Вклинивается другой пототок, проверяем на 0 и забирает товар.
  3. Просыпается первый и забирает товар, в итоге ушли в минус.

Comment on lines +29 to +31
productsCount.set(product, Math.min(maxProductCapacity[product],
productsCount.get(product) + ship.getShipCapacity()));
sleep((productsCount.get(product) - pred) * 1000L / unloadingSpeed);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Тут надо сохранять и использовать локальные перменные, ибо за это время могу придти и стырить и тогда получим неверное время ожидание.

@Rrenkens
Copy link
Copy Markdown
Owner

В итоге 8. +1 за Condition Variable.

@Rrenkens Rrenkens added question Further information is requested and removed invalid This doesn't seem right labels Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants