multithreading - How to assign different methods to different threads in java -
multithreading - How to assign different methods to different threads in java -
i know bit threads in 'c' new them in java. if want create 3 threads, 1 addition, sec subtraction , 3rd multiplication can do
pthread_t maththread[3];
and while creating each thread can assign them different functions in arguments.
void *add(void *arg); void *sub(void *arg); void *mul(void *arg);
in java, if implement runnable interface there 1 run()
method can use. how implement above?
create 3 different runnables:
runnable[] runnables = new runnable[] { new runnable() { public void run() { /* add together code here */ } }, new runnable() { public void run() { /* sub code here */ } }, new runnable() { public void run() { /* mul code here */ } }, };
java multithreading
Comments
Post a Comment