K
K
Konstantin Dovnar2016-12-12 18:21:26
Java
Konstantin Dovnar, 2016-12-12 18:21:26

TimerTask and Thread?

When working with the Timer and TimerTask classes , what is the TimerTask supposed to do in a separate thread? Or is it worth making a separate thread and running it in a TimerTask?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
R
roswell, 2016-12-12
@SolidlSnake

TimerTask inherits the Runnable interface, so it's enough to place the code to execute in the run() method of your own TimerTask descendant class.

R
Rou1997, 2016-12-12
@Rou1997

1) What do you think? Given that the UI does not freeze.
2) There is source code and documentation.

E
Evgeniy Odinets, 2017-04-22
@evgeniy2194

SELECT t1.*, count(t2.*) as count FROM t1 
    INNER JOIN t2 ON t1.id = t2.parent 
        WHERE t1.parent IS NULL
            GROUP BY t2.parent
                HAVING count > 3

Didn't check, but something like that

D
d-stream, 2017-04-22
@d-stream

select 
table.id, min(table.name)
from table
left join table as t2 on t2.paren=table.id
where table.parent is null
group by table.id
having count(t2.parent)>=3

to MySQL to finish to taste and hand in your homework -)

A
Andrey Mikhailov, 2017-04-22
@RainBowAM

For a hierarchy with a depth of 6 elements (maximum), the following query will do:

SELECT
  t1.*
  , count(t2.id) AS count
FROM
  table AS t1
INNER JOIN
  table AS t2 on t1.id = t2.parent
INNER JOIN
  table AS t3 on t2.id = t3.parent
INNER JOIN
  table AS t4 on t3.id = t4.parent
INNER JOIN
  table AS t5 on t4.id = t5.parent
INNER JOIN
  table AS t6 on t5.id = t6.parent
WHERE
  t1.parent IS NULL
GROUP BY
  t1.id
HAVING
  count(t2.id) >= 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question