I've seen a lot of questions on threads and impelementing them using interface, but there doesn't seem to be a lot of updated information on how to do it with a lambda expression. I'm kind of new to this so I'm not sure. The typical one looks like:
Thread myThread = new Thread(() -> {
// Code to be executed inside the thread
});
If I already have a method already defined and imported, can I do this?
Thread myThread = new Thread(() -> myMethod(a, b)); //where a and b are parameters
Basically I just want to run a method in a thread created and that method also requires some parameters to be passed inside it. How do I achieve this? Trying the above with myMethod gives me a threadCPUTime of -1 (Using MXBean) so I am wondering if I am doing it incorrectly. Any help is appreciated.