Ernest Friedman-Hill wrote:The compiler error is presumably due to that stray semicolon after r2.getId(): it should be a comma, of course.
Yes, i corrected that...it was the problem. (This is so embarrassing)
Ernest Friedman-Hill wrote:
First, I don't understand what this program tells you about when the IDs are assigned; wouldn't you want to check the id of a single thread both before and after starting it to explore that question?
I did that just now by getting ID's immediately after the new Thread() code. And the program runs as per expectation. So a thread is considered "created" when we instantiate a thread.
Perhaps oracle could add that.
Ernest Friedman-Hill wrote:
But second: when your Java code starts, there are many other threads already running: the main one, of course, and then several having to do with garbage collection, finalization, deadlock detection, etc.
Nice ! i was not aware of that. Suppose there are more programs running, each having their own threads, could that affect the numbers in my program ?
I hope i am not asking a foolish question ? Please tell me if thinking on these lines need higher concepts.
thanks