You can wrap with Runnable,
Thread thread = new Thread(new Runnable() {
public void run() {
// Call the function here.
}
);
thread.start();
Thank's
but in my program i have a main class which is a server it runs forever.
from the main class when i call a function it runs in a separate thread and returns the result to the callee and the main function continue it's work
class server
{
//this function when called must be in separate thread
public int function(int x)
{
//there could be wait here or sleep
return x*2;
}
public static void main(String[] args)
{
// Run RMI server
}
}
i hope u understand me!!!
Thank's
All you need can be found in the referenced tutorial, Jeff linked to in reply #3. It won't be quicker to ask concurrency basics step by step in this forums. If you have doubt on the concept of concurrency in general, do yourself a favour and get a good book (some also mentioned in the tutorial).
> Thank's
>
> but in my program i have a main class which is a
> server it runs forever.
> from the main class when i call a function it runs in
> a separate thread and returns the result to the
> callee and the main function continue it's work
Previous answers apply.