|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--com.tagtraum.perf.classloading.BackgroundClassLoader
Loads and initializes classes in a separate thread. You may want to disable
class garbage collection with the VM command line parameter -Xnoclassgc
in order for this to have an effect.
This class is especially useful, when classes shall be loaded over a slow network, but aren't packaged in a zip or jar file. However, consider doing just that (using zip or jar files), before you try to enhance performance by using this class.
You may also use this class to preload and preinitialize classes, if you need a lot of classes later on in the life of your application. When you actually have to instantiate a class, you don't need to load and initialize it anymore. This may make applications slightly more responsive.
You may obtain a list of classes you might want to preload by running your application with the
-verbose:class
VM command line parameter.
Class.forName(java.lang.String)
,
Class.forName(java.lang.String, boolean, java.lang.ClassLoader)
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
BackgroundClassLoader(java.lang.String[] classnames)
Loads and initializes classes in a separate thread. |
|
BackgroundClassLoader(java.lang.String[] classnames,
boolean initialize,
java.lang.ClassLoader classLoader)
Loads and optionally initializes classes in a thread. |
Method Summary | |
void |
run()
Loads the classes. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public BackgroundClassLoader(java.lang.String[] classnames)
Thread.MIN_PRIORITY
. You need to call Thread.start()
, to start loading.
classnames
- array of fully qualified classnamespublic BackgroundClassLoader(java.lang.String[] classnames, boolean initialize, java.lang.ClassLoader classLoader)
Thread.MIN_PRIORITY
. You need to call Thread.start()
, to start loading.
initialize
- if true, the loaded class is initializedclassnames
- array of fully qualified classnamesclassLoader
- the ClassLoader to useMethod Detail |
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |