i have been working on a rather large plugin and i NEED to implement threading. i have been driving myself crazy with an issue tho. it seems to me that if i create a new thread the API creates hundreds of new threads. i have done some testing and i dont no think it is my code. any input would be helpful.
public void initPlayer(Player player){
if(rpCore.getConfig().getDevConfig().getMultiThreadEnabled()){
Thread initThread = new Thread(new InitPlayer(rpCore, player, rpCore.getConfig().getDevConfig().getMultiThreadEnabled()));
new InitPlayer(rpCore, player, rpCore.getConfig().getDevConfig().getMultiThreadEnabled());
//class init player called from Init method
public InitPlayer(RPCore rpCore, Player player, Boolean multiThreadEnable) {
this.multiThreadEnable = multiThreadEnable;
playerMenus = new HashMap<>();
implementingMenuElement = new HashMap<>();
implementingSettingsElement = new HashMap<>();
println("Running InitPlayer NON-Threaded",10);
println("Running InitPlayer Threaded "+Thread.currentThread().getName(),10);
private void initPlayerSettings(){
HashMap<String, String> settings = rpCore.getDatabaseManager().getSettingsDBController().getPlayerSettings(player.getUID());
ps = new PlayerSettings(rpCore);
ps.setBackgroundName(settings.get("backgroundName"));
ps.setBackgroundImage(rpCore.getAssets().getImages().getImageByName(settings.get("backgroundName")));
ps.setHeaderFont(Font.valueOf(settings.get("headerFont")));
ps.setHeaderFontSize(Float.parseFloat(settings.get("headerFontSize")));
ps.setHeaderFontColor(Integer.parseInt(settings.get("headerFontColor")));
ps.setTextFont(Font.valueOf(settings.get("textFont")));
ps.setTextFontSize(Float.parseFloat(settings.get("textFontSize")));
ps.setTextFontColor(Integer.parseInt(settings.get("textFontColor")));
ps.setBorderColor(Integer.parseInt(settings.get("borderColor")));
ps.setBorderSize(Float.parseFloat(settings.get("borderSize")));
ps.setButtonBackgroundColor(Integer.parseInt(settings.get("buttonBackgroundColor")));
ps.setButtonBorderColor(Integer.parseInt(settings.get("buttonBorderColor")));
ps.setButtonFontColor(Integer.parseInt(settings.get("buttonFontColor")));
ps.setButtonFontSize(Float.parseFloat(settings.get("buttonFontSize")));
ps.setButtonFont(Font.valueOf(settings.get("buttonFont")));
ps.setButtonBorderSize(Float.parseFloat(settings.get("buttonBorderSize")));
ps.setMenuFont(Font.valueOf(settings.get("menuFont")));
ps.setMenuFontColor(Integer.parseInt(settings.get("menuFontColor")));
ps.setMenuFontSize(Float.parseFloat(settings.get("menuFontSize")));
ps.setInteractionKey(Key.valueOf(settings.get("interactionKey")));
ps.setInteractionOptionKey(Key.valueOf(settings.get("interactionOptionKey")));
ps.setHideMenuOnExit(Boolean.parseBoolean(settings.get("hideMenuOnExit")));
ps.setHideInfoTextOnExit(Boolean.parseBoolean(settings.get("hideInfoTextOnExit")));
ps.setMainMenuPositionX(Float.parseFloat(settings.get("mainMenuPositionX")));
ps.setMainMenuPositionY(Float.parseFloat(settings.get("mainMenuPositionY")));
ps.setMainMenuSizeX(Float.parseFloat(settings.get("mainMenuSizeX")));
ps.setMainMenuSizeY(Float.parseFloat(settings.get("mainMenuSizeY")));
ps.setMainPanelPositionX(Float.parseFloat(settings.get("mainPanelPositionX")));
ps.setMainPanelPositionY(Float.parseFloat(settings.get("mainPanelPositionY")));
ps.setMainPanelSizeX(Float.parseFloat(settings.get("mainPanelSizeX")));
ps.setMainPanelSizeY(Float.parseFloat(settings.get("mainPanelSizeY")));
if(rpCore.getConfig().getBaseConfig().getGeneralConfig().getDebugTextEnabled()) {
Display More
println("[RPCore/PlayerSettings]" , 9);
for (Map.Entry<String, String> entry : settings.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
println("\t "+key+": -> "+value, 14);
logs to show what i think is an issue
Threaded threaded console output.txt
NON-Threaded non threaded consol output.txt
Again it may be me but o do not believe it is.