I would assume that the answer is no.
The GC is concidered part of the security mechanisms in Java, as the GC will prevent hostile attempts on trying to break the JVM by allocating extreme amounts of data.
However I cannot say that I know this 100%, and what is more, the java-spec for the GC does not explicitely say either (I am told). And if you try to run the follwing code, you can see that the GC in run in between even tho the running thread has MAX_PRIORITY:
import java.util.*;
public class GCTest
{
private long[] longs = new long[ 1000 ];
static void main( String[] args )
{
Thread t = new Thread( createRunnable() );
t.start();
}
static Runnable createRunnable()
{
return new Runnable()
{
public void run()
{
GCTest.allocateAlot();
}
};
}
static void allocateAlot()
{
System.out.println( "Entered allocating method. Free memory:" + Runtime.getRuntime().freeMemory() );
Thread.currentThread().setPriority( Thread.MAX_PRIORITY );
try
{
ArrayList list = new ArrayList();
while( true )
{
list.add( new GCTest() );
}
}
catch( Throwable ex )
{
ex.printStackTrace();
// Call it again!
allocateAlot();
}
}
}