arraylist « Development « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Development » arraylist 

1. ArrayList and Multithreading in Java    stackoverflow.com

Under what circumstances would an unsynchronized collection, say an ArrayList, cause a problem? I can't think of any, can someone please give me an example where an ArrayList causes a ...

2. Data race in Java ArrayList class    stackoverflow.com

I was reading about CopyOnWriteArrayList and was wondering how can I demonstrate data race in ArrayList class. Basically I'm trying to simulate a situation where ArrayList fails so that it becomes ...

3. java.util.ConcurrentModificationException on ArrayList    stackoverflow.com

I have a Server class and a Timer inside it which is supposed to clear dead clients (clients who crashed). I followed the example below by locking the collection when the ...

4. Problems with two threads accessing a frequently updated Arraylist    stackoverflow.com

I have ArrayLists that store many objects, and objects are frequently added and removed from the ArrayLists. One thread operates on the data structures and updates the ArrayList's objects every 20ms ...

5. Way to use an ArrayList without ConcurrentModificationException(s)?    stackoverflow.com

JAVA I have an ArrayList in my game to store all the particles ingame. I have an update method which accesses the ArrayList to update the physics, I have a render method ...

6. ArrayList - add "same" objects (same => equals, hashCode), Threads    stackoverflow.com

Ive got one question. What happens when I try to add the "same" object twice to an ArrayList. With "the same" I mean an object of an individual class, which is ...

7. Java Game: ArrayList and Iterator vs. Thread    stackoverflow.com

Sup guys. I'm writing a simple zombie game for my Java classes and I'm struck with a little problem: the Zombies are a class I made and I'm treating them on an ...

8. Using ArrayList to Store Class which Extends Thread    stackoverflow.com

I have a driver class called Advantech which is stored inside an ArrayList. I instantiate and initialize my class. The Advantech class extends Thread and the Advantech class has a run() ...

9. Snake Game Program - Making the Body of the Snake    stackoverflow.com

EDIT: (QUESTION ANSWERED)


So I have a Thread controlling x and y and making it change. My problem is that when the snakes body gets put up in the GUI it puts ...

10. java.util.ConcurrentModificationException Exception error    stackoverflow.com

i am trying to make a java application with GUI. i am writing a code that i want to let the User change some data and save these changes on a ...

11. Best practice to avoid java.util.ConcurrentModificationException when using ArrayList    stackoverflow.com

I have an ArrayList that I want to iterate over it. While iterating over it I have to remove elements at the same time. Obviously this trhows an java.util.ConcurrentModificationException. What is ...

12. I need help on ArrayList    coderanch.com

13. how to synchoronize a ArrayList    coderanch.com

Well, if you have multiple threads(i mean, not taking the same runnable parameter), then, you can synchronize the getter and setter methods at the class level. synchronized(Myclass.class) {// code goes here } If all the thread objects access this class where the ArrayList object is there, then, you can synchronize the getter and setter methods at the object level. synchronized(this) {// ...

14. Synchronised ArrayList ?    coderanch.com

[Nitesh]: BTW, you do not need to do anything on your own. Collections.synchronizedList(java.util.List) will do it for you. Hm, I doubt it. Usually you need to add explicit, external synchronization somewhere, in order to get useful, reliable results. Well, maybe if you put in some other restrictions, things "no more than one thread may ever remove elements from the list", or ...

15. Thread adding doubles to an ArrayList in a different class    coderanch.com

import java.util.*; public class TheClass implements Runnable { List arrList = new ArrayList(); int total; public void run() { for(int i : this.arrList) { this.total += i; } System.out.println(this.total + ", " + Thread.currentThread().getName()); } public static void main(String[] args) { TheClass obj = new TheClass(); obj.arrList.add(3); obj.arrList.add(5); obj.arrList.add(6); Thread t1 = new Thread(obj, "OurThread"); t1.start(); // You can do rest ...

16. Threads, that processed two shared ArrayLists like Queue    coderanch.com

Hello, I'm newbie. So, excuse me if my question is stupid. Sorry for my english, too. I'm trying to build this functionality: Let's say that we have two ArrayLists: - keywordsToProcess - currentKeywords The idea is that I want to process keywordsToProcess with countless threads. As keywordsToProcess processing is limited to taking the first element (index 0), then I do things ...

17. java.util.ConcurrentModificationException with ArrayList    coderanch.com

Hi All, I have code that looks like this: List studentsList = getStudentsList(); List allStudents = new ArrayList(); if (studentsList!=null && studentsList.size()>0){ for(Object d: studentsList){ if(d instanceof Student){ ((Student)d).setType("Fresher"); ((Student)d).setDesc("This is a newly joined student"); allStudents.add(d); } } } Now, my question is: 1. I saw some intermittent errors which complained about java.util.ConcurrentModificationException. Is the above code not threadsafe? 2. Can ...

19. ConcurrentModificationException in ArrayList    forums.oracle.com

20. Drawing2D / ArrayList / Threading    forums.oracle.com

It may be just me, but I'm having a tough time figuring out exactly what you are trying to do based on your explanation. Perhaps you need to write out a more complete paragraph that explains what you are trying (in non-programming terms) as if we were 12 year olds. That is unless a more intelligent soul can make sense of ...

21. IndexOutOfBounds Exception using ArrayList running in a Thread    forums.oracle.com

First of all, put your program code between {code} tags. Nobody's going to read unformatted code. Secondly, IOOBE is a very simple to understand exception. You're accessing a collection beyond its limits. Thirdly, the stacktrace will tell you where this happens. If you have multiple threads involved, you might need appropriate synchronization in there.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.