As for the BEGIN block, it seems to work well. Aside from some complaints about freed pools that randomly occur when closing the application, i haven't noticed any problems.
Regarding two main-loops, yea, that does indeed not work. As soon as the first mainloop in the thread starts the whole application closes. But that's no big problem, as
Corion below already provided the exact thing i needed. :)