Passing thread-IDs via global variables is nothing ugly unless these are "constant".In your case, since threads are created on start-up the thread-id won't change later on.Regarding your problem, the simplest thing is to activate the interrupt from within the foreground thread.So it is sure the global thread-id is valid.