Do not use a Static int variable. Use a vector, in your thread constructor, pass the vector to your thread, when the thread found a prime number, add it to the Vector (as
String) and make the thread print that number to the System.out To be more nice, make your thread constructor method taking a OutputStream and pass the System.out as argument.
In that way, your prime number will be display where ever your want and you will have the prime number in a vector for further use