I'm not sure why you'd want to do this, other than if this is a homework assignment. Either way, the tutorial I linked to you contains explanations for everything you'd need to do.
Keep in mind that threads don't have any magic rules that normal code doesn't. There is no "jumping" around in the code, other than the normal ways. Also, keep in mind that just because you're seeing a certain output most of the time, that doesn't mean it'll work that way every time you run it- you have no synchronization over here, so you can't control (or predict) which order things happen in.