I have a class with name Socket that have tow function for example func1 and func2
fucn1() {
while(true) {
...
}
}
fucn2() {
while(true) {
...
}
}
I want two of them run with thread in a time and concurrently. how can i do that??
class socket implement Runnable {
public void run() {
func1();
func2();
}
}
In this code only first function is executed not second. How can i do for concurrently run both of them?
My Suggestion is :
Instead of making socket
ClassRunnable,Create two
Runnablethreads as in my example below and call your functions from there. And start these two threads from yourSocketclass.