Skip to content

Ohloblia Module 2#1

Open
mxk77 wants to merge 17 commits into
masterfrom
simulation
Open

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

Conversation

@mxk77
Copy link
Copy Markdown
Owner

@mxk77 mxk77 commented Jan 30, 2025

No description provided.

Copy link
Copy Markdown

@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) {
Copy link
Copy Markdown

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);
Copy link
Copy Markdown

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++;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
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) {
Copy link
Copy Markdown

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