ASF Bugzilla – Attachment 27656 Details for
Bug 51919
Random ConcurrentModificationException or NoSuchElementException in CookieManager#removeMatchingCookies when using Concurrent Download
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Example of ConcurrentModificationException with Collections.synchronizedCollection
TestConcurrent.java (text/plain), 1.30 KB, created by
Philippe Mouawad
on 2011-10-01 12:51:27 UTC
(
hide
)
Description:
Example of ConcurrentModificationException with Collections.synchronizedCollection
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2011-10-01 12:51:27 UTC
Size:
1.30 KB
patch
obsolete
>package org.apache.jmeter.protocol.http.sampler; > >import java.util.ArrayList; >import java.util.Collections; >import java.util.Iterator; >import java.util.List; > >public class TestConcurrent { > > public static void main(String[] args) { > > final List<String> concList = Collections.synchronizedList(new ArrayList<String>()); > for (int i = 0; i < 100; i++) { > concList.add(""+i); > } > > for (int i = 0; i < 2; i++) { > final int threadId = i; > Thread t = new Thread(new Runnable() { > > public void run() { > Iterator<String> it = concList.iterator(); > while(it.hasNext()) > { > String s = it.next(); > if(threadId%2==0) > { > if((Integer.parseInt(s) % 2==0)) > { > it.remove(); > } > } > try { > Thread.sleep(100); > } catch (InterruptedException e) { > // nOOp > } > } > } > }); > t.start(); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 51919
:
27636
|
27643
|
27654
| 27656 |
27657
|
27716