mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-26 18:11:40 +01:00
Fixed thread safety
This commit is contained in:
parent
d4bf3bd2ec
commit
cc203b1a1a
@ -11,10 +11,9 @@ public class EntityManager {
|
||||
|
||||
private Set<LivingEntity> livingEntities = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
private ExecutorService pool = Executors.newFixedThreadPool(5);
|
||||
private ExecutorService pool = Executors.newFixedThreadPool(50);
|
||||
|
||||
public void update() {
|
||||
|
||||
livingEntities.removeIf(livingEntity -> livingEntity.shouldRemove());
|
||||
|
||||
synchronized (livingEntities) {
|
||||
|
@ -11,7 +11,6 @@ public class ChickenCreature extends EntityCreature {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
//System.out.println("Update poulet");
|
||||
onGround = true;
|
||||
|
||||
double speed = 0.01;
|
||||
|
@ -3,12 +3,14 @@ package fr.themode.minestom.net;
|
||||
import fr.themode.minestom.entity.Player;
|
||||
import fr.themode.minestom.net.player.PlayerConnection;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConnectionManager {
|
||||
|
||||
private Set<PlayerConnection> connections = new HashSet<>();
|
||||
private Map<PlayerConnection, Player> connectionPlayerMap = new HashMap<>();
|
||||
private volatile Map<PlayerConnection, Player> connectionPlayerMap = new HashMap<>();
|
||||
|
||||
public Player getPlayer(PlayerConnection connection) {
|
||||
return connectionPlayerMap.get(connection);
|
||||
|
Loading…
Reference in New Issue
Block a user