473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

synchronizedSortedMap and Iterators

hello,

I have been wondering as to what extent the SortedMap that
synchronizedSortedSet( new TreeMap() ) returns is synchronized, and
thought that somebody might be able to help.

If I get the iterator from the sorted set is the iterator also
synchronized?
If another thread attempts to access the sorted set while the iterator
exists will an exception be thrown? or will the thread block and wait
for the iterator to be finished with?

I remember reading something about exceptions being thrown if the data
in the Map or set that an iterator is from, is changed. I cannot find
where I read this, so I might have made it up.

Any pointers will be a great help,

Thanks

Matt Melton
Jul 17 '05 #1
1 1928
Hello me,
I'm posting this in response to my question that I have found the
answer to.
The answer is not very.

The synchronization applies only to the SortedMap not the Iterator.
If the Map is altered then the iterator MAY throw a
ConcurrentModificationException though this is not always the case. So
instead of using the iterator, is there someway of getting what you
need without iterating through the map itself, and storing the
reference(s) someplace else?
At least that way you have a snapshot of the Map even though it may
not be current. At least it won't break.
This may or may not be what you need.
It's ok for what I intend.

Good Luck

Matt Melton

ha***********@yahoo.co.uk (matt melton) wrote in message news:<26**************************@posting.google. com>...
hello,

I have been wondering as to what extent the SortedMap that
synchronizedSortedSet( new TreeMap() ) returns is synchronized, and
thought that somebody might be able to help.

If I get the iterator from the sorted set is the iterator also
synchronized?
If another thread attempts to access the sorted set while the iterator
exists will an exception be thrown? or will the thread block and wait
for the iterator to be finished with?

I remember reading something about exceptions being thrown if the data
in the Map or set that an iterator is from, is changed. I cannot find
where I read this, so I might have made it up.

Any pointers will be a great help,

Thanks

Matt Melton

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Steven Bethard | last post by:
So, as I understand it, in Python 3000, zip will basically be replaced with izip, meaning that instead of returning a list, it will return an iterator. This is great for situations like: zip(*)...
18
by: deancoo | last post by:
I have gotten into the habit of often using copy along with an insert iterator. There are scenarios where I process quite a lot of data this way. Can someone give me a general feel as to how much...
1
by: Marcin Kaliciñski | last post by:
template<class RanAccIt> void some_algorithm(RanAccIt begin, RanAccIt end) { // this algorithm involves calling std::lexicographical_compare // on range [begin, end), and on reverse of this range...
3
by: codefixer | last post by:
Hello, I am trying to understand if ITERATORS are tied to CONTAINERS. I know the difference between 5 different or 6(Trivial, on SGI). But what I fail to understand is how can I declare all 5...
8
by: babak | last post by:
Hi everyone I have a problem with Iterators and containers in STL that hopefully someone can help me with. This is what I try to do: I have an associative (map) container and I have a...
24
by: Lasse Vågsæther Karlsen | last post by:
I need to merge several sources of values into one stream of values. All of the sources are sorted already and I need to retrieve the values from them all in sorted order. In other words: s1 = ...
14
by: Jiri Kripac | last post by:
Languages such as Simula 67 contain a general concept of coroutines that allow the execution of a method to be suspended without rolling back the stack and then later resumed at the same place as...
2
by: ma740988 | last post by:
typedef std::vector < std::complex < double > > complex_vec_type; // option1 int main() { complex_vec_type cc ( 24000 ); complex_vec_type dd ( &cc, &cc ); } versus
90
by: John Salerno | last post by:
I'm a little confused. Why doesn't s evaluate to True in the first part, but it does in the second? Is the first statement something different? False print 'hi' hi Thanks.
18
by: desktop | last post by:
1) I have this code: std::list<intmylist; mylist.push_back(1); mylist.push_back(2); mylist.push_back(3); mylist.push_back(4);
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.