I use a desktop with eight cores to build a Java application using Ant (through a javac target). Is there a way to speed up the compilation by using more than one thread or
As long as the javac you are calling doesn't use all the cores it doesn't really matter what you say in Ant. You can use the compiler attribute to define which java compiler should be used for the task.
If you have several build targets you can use fork=yes to execute the target(s) externally.
http://ant.apache.org/manual/Tasks/javac.html#compilervalues