Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Wait Time/Queue

Thread view: 
Jason Cavett - 06 Jun 2007 19:04 GMT
I have an interesting problem and I'm wondering if anybody has ever
run across it.

Part of the application I am developing is a BlockingQueue which waits
for an object to be placed on the queue.  When the object is placed on
the queue, the object is taken off the blocking queue and actions are
performed on it.

The problem is that the object can be added to the BlockingQueue many
times in quick succession.  Additionally, the actions performed on the
object take awhile to complete (and is pretty processor intensive -
even though the task is on a different thread).  What I am wondering
is whether or not there is a way to keep taking the object (as it
changes -- it's always the same object, though) off the BlockingQueue
and assigning it to a variable but waiting for "X" to happen where "X"
is the system sits idle or something like that (which allows the user
to make many updates and THEN the checks are determined).

Other than a few things I found while searching, I haven't found a
whole lot.  Any help pointing me in the right direction would be
great.

P.S.  It seems like Eclipse does something like this between quick
compiles - the user types a bunch of stuff out, but Eclipse only
performs the compile/check/etc. when the user stops for a period of
time.
Daniel Pitts - 06 Jun 2007 20:02 GMT
> I have an interesting problem and I'm wondering if anybody has ever
> run across it.
[quoted text clipped - 22 lines]
> performs the compile/check/etc. when the user stops for a period of
> time.

a BlockingQueue doesn't seem like the appropriate tool to use for this
job.

I would probably create a thread that does the work, but waits on a
condition. see Lock.getCondition()

The part of your code that used to put the object into the blocking
queue would instead start a timer or reset an existing timer. The
timer would make the condition true, so that your worker thread does
the work it needs to.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.