Thanks for your reply.
Maybe the example looks a bit weird because i deleted all code that isnt necessary to show my problem.
I want to use threads cause i feel the communication is easier than with processes. If i create process and a pipe for communication this would result in something like