• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Blocking I/O using Iterator()

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In profiling my java application I noticed that the iterator() method was blocking on the arraylist data structure.
Is it better to use the get() method to remove the block or stick with the iterator?
 
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a very strange symptom you describe. What does it have to do with I/O? Do you mean blocking in the sense that threads block when they try to enter a synchronized block or method, and can't, because they can't acquire the lock? Probably not, but that's what block usually means. Or do you just mean that your program spends too much time executing this method? That's surprising to me. Are you sure the problem is really with the iterator() method, and not in other methods called on the Iterator, like hasNext() or next()?
 
Matt Elliott
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike, you're right.
I was just miss interpreting the profiler's results, but in re-examining it, it lead my to the question:
Is the new keyword synchronized, in the sense that multiple threads can't instantiate data structures simultaneously?
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, new is not synchronized.
 
Arthur, where are your pants? Check under this tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic