Skip to content

Lab2#35

Open
DaniilDomnin wants to merge 9 commits into
Rrenkens:mainfrom
DaniilDomnin:lab2
Open

Lab2#35
DaniilDomnin wants to merge 9 commits into
Rrenkens:mainfrom
DaniilDomnin:lab2

Conversation

@DaniilDomnin
Copy link
Copy Markdown

No description provided.

@Rrenkens Rrenkens added the invalid This doesn't seem right label Dec 6, 2022
this.docks = docks;
ship_count = new AtomicInteger();
consoleLOgger = Logger.getLogger(" ");
Thread thread = new Thread(docks::StartStealing);
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.

Не стоит делать такое в конструкторе.


private void Generating() throws InterruptedException {
while (true) {
if (ship_count.get() < max_ships) {
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 +24 to +35
if (ship_count.get() < max_ships) {
Ship ship = generator.GenerateShip();
consoleLOgger.log(Level.INFO, "Generate new ship");
Thread thread = new Thread(()->{
try {
Uploading(ship);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
thread.start();
ship_count.incrementAndGet();
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.

Между этими строчками можем произойти множество событий и кораблей сюда зайдет намного больше чем max_ship и ship_count может даже в минус уйти. И не хорошо оставлять висеть потоки.

@Rrenkens
Copy link
Copy Markdown
Owner

Очень плохая декомпозиция, но по требованиям подходит.

В итоге 8.

@Rrenkens Rrenkens added question Further information is requested and removed invalid This doesn't seem right labels Dec 24, 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