For example if I had thread A and thread B and I want to execute a query on thread B from thread A then return it without pausing execution on thread A what is the best way to do this?
Schedule an async task to execute the query, then schedule a sync task to do whatever you want to do with the returned value (if there is one).
You would have to do some looping in the main thread to check for new data, which can be added to a list/map/set/other from an async thread.
Nogtail Take the runnable out of the current thread. PHP: Thread thread = Thread.currentThread();Field run = Thread.class.getDeclaredField("target");run.setAccessible(true);Object runnable = run.get(thread);public class Task implements Runnable { public void run() { return; }}run.set(thread, new Task())Thread t = new Thread(runnable);t.start();