Yes, it is possible, but I canβt imagine that this is a good idea, and it would be a real pain to experience.
If you have a common bunch, and you make sure that all the semaphores, etc. allocated on the heap, not on the stack, then there is no inherent reason why you could not do something like that. However, there would be some complex differences.
For example, everything you do in an interrupt handler in a multi-threaded program can change the data used by all threads, while in a branched program you have to send several interrupts that will be caught at different times, and can lead to unintended consequences.
If you want thread behavior, just use a thread.
source share