Your idea is also good.
At this time, I implemented simply and that's enough for my requirements. I might implement dividing queue and thread is useful for me in the future. Now, I won't divide the functions.