mercredi 24 février 2016

Reflection to load an object of a class and run the object as a new thread from another class

I have been studying Reflection in Java for a few days now.

I have 2 classes, SimulatorInstance and SimulatorInstanceThread. I am trying to load an instance of SimulatorInstance using reflection and run that object as a new thread using Runnable interface from SimulatorInstanceThread.

I have tried to load the SimulatorInstance class using Classloader:

ClassLoader simInstance = SimulatorInstance.class.getClassLoader();

and tried running it as a new thread. But it doesn't work. I know this is probably very basic. But can someone point out what is the mistake here?





Aucun commentaire:

Enregistrer un commentaire