Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Huilo extends Thread {
- private final Queue<Runnable> queue = Queues.newArrayDeque();
- @Override
- public void run() {
- synchronized(queue) {
- while(queue.isEmpty()) {
- queue.poll().run();
- }
- }
- }
- // И в таске может быть овер сложная задача, которая займет дохуя мс
- public void runTask(Runnable task) {
- synchronized(queue) {
- queue.add(task);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement