Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new to Java multithreading

 
Gabry ombo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm new to multithreading programming.
I have a problem with this :

  • There is a Thread that manage requests
  • There are many Threads that make requests to the Manager


  • When there aren't any active requests, the manager must sleep but when arrive one request
    the manager must take this active request and start your job.
    If arrive one other request, it will be positioned into a queue and his
    owner thread will be suspended
    When the Manager's job will be finished will be taken another request from the queue

    How can I suspend and put a Thread in a queue and then restarting it ?


    Thanks for any suggestion
     
    Henry Wong
    author
    Marshal
    Pie
    Posts: 21199
    81
    C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    In threading speak, the task of waiting for work, is generally done by a condition variable. And in Java, condition variable functionality are done with the wait() and notify() methods.

    How about starting with Sun tutorial -- and learning up to about synchronization and the wait and notify mechanism?

    http://java.sun.com/docs/books/tutorial/essential/concurrency/

    Henry

     
    Sergey Babkin
    author
    Ranch Hand
    Posts: 50
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There is allso Java Message Queue API:

    http://docs.sun.com/app/docs/doc/820-5205/aeqcq?l=en&a=view&q=java+queue
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic