Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in Threads !!!!!

 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .....
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Threads can be a difficult topic to work.

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.

    What would happen, how would one write the code ?

    See:
  • A question from Java Concurrency in Practice
  • Threads and Synchronization -> practical applications of threads/synchronization
  • Failure mode of two reference calls to one thread in which I ultimately went back and admitted I had the question wrong.



  • Don't feel lonely, Read Henry's book - it uses understandable language and gives numerous points that are of great utility in grasping the concept.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic