Hi all, I need Help in Threads.... I am very weak in threads......i am not able to understand the concepts...... theory wise i am a little ok ...but practically i am not able to understand the concepts from the ground up ..... Please help me in understanding threads practically .... please provide me with simple practical examples by which i can learn the basic concepts of threads..... I am not able to find any good example of threads on net .....Thanks in advance .....
I have come to realize that threads are the machine in operation.
Say if you write:
Thread t = new Thread(object); t.start();
it becomes extremely difficult to people to get the idea that the code you have written is not the thread it's self, a Thread has two things to think about:
The code you wrote.
The machine in execution.
You write some code, then the machine will execute the run() method for you - one time - separately from where you started it - then that thread has "run". In so doing, you can accomplish work in "two places at once" as though there were two computers running. Each thread of execution, while running, may be thought of as a computer running. Keeping track of what is where becomes the subject of much discussion, but ofen overlooks the "computational machinery running as a machine" side of the discussion.
Say you had two calculators in class, or two wristwatches or two soccer game video devices or whatever, side by side, but would only write the code one time.