Skip to content

Ohloblia Module 2#1

Open
mxk77 wants to merge 17 commits intomasterfrom
simulation
Open

Ohloblia Module 2#1
mxk77 wants to merge 17 commits intomasterfrom
simulation

Conversation

@mxk77
Copy link
Owner

@mxk77 mxk77 commented Jan 30, 2025

No description provided.

Copy link

@Fabolo12 Fabolo12 left a comment

Choose a reason for hiding this comment

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

Загалом проект добре зроблений

Comment on lines +209 to +211
try {
future.get();
} catch (InterruptedException | ExecutionException e) {

Choose a reason for hiding this comment

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

Не оптимальний спосіб очікування, тому що блокується потік

Comment on lines +119 to +120
// Чекаємо на завершення всіх задач
waitForAllFutures(futures);

Choose a reason for hiding this comment

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

Взагалі, якщо результат, що повертається, не важливий, то використовувати Future для маркера завершеності це занадто ускладнювати систему

Comment on lines +164 to +177
synchronized (this){
ateThisTick++;
}
if (animal instanceof Predator){
synchronized (this){
eatenThisTick++;
}
}
}
if (animal.multiply()){
synchronized (this){
bornThisTick++;
}
}

Choose a reason for hiding this comment

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

Краще зробити один великий блок синхронізації

Copy link
Owner Author

Choose a reason for hiding this comment

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

зрозумів, дякую!

spawnPlants(Plant.class);
}

private <T extends Animal> void spawnAnimals(Class<T> animalClass) {

Choose a reason for hiding this comment

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

Цікаве рішення

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