Good day. How to make the methods that are in a particular class run in a separate thread?
extends Thread won't it help?
Good day. How to make the methods that are in a particular class run in a separate thread?
extends Thread won't it help?
Check out https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Callable.html
description and example here: http://cybern.ru/urok-4-vozvrat-znachenij-iz-zadach-interfejs-callable.html
You need to transfer the object of your class to the Threads class constructor, then override the run () method, in which you will call your methods. Either implement the Runnable interface and also redefine the run () method (better option with Runnable, since you may need to inherit your class from another class).
Source: https://ru.stackoverflow.com/questions/513791/
All Articles