Created
April 15, 2020 07:43
-
-
Save aikar/90d9bf4634f857c5395d85a3bbf29207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package a.a.a; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
public final class A extends JavaPlugin { | |
ClassLoader loader; | |
static Executor pool = Executors.newCachedThreadPool(); | |
@Override | |
public void onEnable() { | |
loader = this.getClassLoader(); | |
} | |
public void load() { | |
pool.execute(this::loadCls); | |
pool.execute(this::loadCls); | |
pool.execute(this::loadCls); | |
} | |
public void loadCls() { | |
try { | |
System.out.println(Thread.currentThread().getName() + " started"); | |
getClassLoader().loadClass("a.a.a.SomeClass"); | |
System.out.println(Thread.currentThread().getName() + " done"); | |
} catch (ClassNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package a.a.b; | |
import a.a.a.A; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
public final class B extends JavaPlugin { | |
ClassLoader loader; | |
static Executor pool = Executors.newCachedThreadPool(); | |
A a; | |
@Override | |
public void onEnable() { | |
loader = this.getClassLoader(); | |
a = (A) getServer().getPluginManager().getPlugin("A"); | |
pool.execute(this::load); | |
} | |
public void load() { | |
pool.execute(this::loadCls); | |
pool.execute(this::loadCls); | |
pool.execute(this::loadCls); | |
a.load(); | |
} | |
public void loadCls() { | |
try { | |
System.out.println(Thread.currentThread().getName() + " started"); | |
getClassLoader().loadClass("a.a.a.SomeClass"); | |
System.out.println(Thread.currentThread().getName() + " done"); | |
} catch (ClassNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment