Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/util/concurrent/ConcurrentHashMap.java
          +++ new/src/share/classes/java/util/concurrent/ConcurrentHashMap.java
↓ open down ↓ 1262 lines elided ↑ open up ↑
1263 1263  
1264 1264      /**
1265 1265       * Save the state of the <tt>ConcurrentHashMap</tt> instance to a
1266 1266       * stream (i.e., serialize it).
1267 1267       * @param s the stream
1268 1268       * @serialData
1269 1269       * the key (Object) and value (Object)
1270 1270       * for each key-value mapping, followed by a null pair.
1271 1271       * The key-value mappings are emitted in no particular order.
1272 1272       */
1273      -    private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
     1273 +    private void writeObject(java.io.ObjectOutputStream s) throws IOException {
1274 1274          s.defaultWriteObject();
1275 1275  
1276 1276          for (int k = 0; k < segments.length; ++k) {
1277 1277              Segment<K,V> seg = segments[k];
1278 1278              seg.lock();
1279 1279              try {
1280 1280                  HashEntry<K,V>[] tab = seg.table;
1281 1281                  for (int i = 0; i < tab.length; ++i) {
1282 1282                      for (HashEntry<K,V> e = tab[i]; e != null; e = e.next) {
1283 1283                          s.writeObject(e.key);
↓ open down ↓ 7 lines elided ↑ open up ↑
1291 1291          s.writeObject(null);
1292 1292          s.writeObject(null);
1293 1293      }
1294 1294  
1295 1295      /**
1296 1296       * Reconstitute the <tt>ConcurrentHashMap</tt> instance from a
1297 1297       * stream (i.e., deserialize it).
1298 1298       * @param s the stream
1299 1299       */
1300 1300      private void readObject(java.io.ObjectInputStream s)
1301      -        throws IOException, ClassNotFoundException  {
     1301 +        throws IOException, ClassNotFoundException {
1302 1302          s.defaultReadObject();
1303 1303  
1304 1304          // Initialize each segment to be minimally sized, and let grow.
1305 1305          for (int i = 0; i < segments.length; ++i) {
1306 1306              segments[i].setTable(new HashEntry[1]);
1307 1307          }
1308 1308  
1309 1309          // Read the keys and values, and put the mappings in the table
1310 1310          for (;;) {
1311 1311              K key = (K) s.readObject();
1312 1312              V value = (V) s.readObject();
1313 1313              if (key == null)
1314 1314                  break;
1315 1315              put(key, value);
1316 1316          }
1317 1317      }
1318 1318  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX