Add thread name to patterns

This implements a `%thread` pattern that outputs current thread name.