File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Multiple Thread allow to change single variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Multiple Thread allow to change single variable" Watch "Multiple Thread allow to change single variable" New topic
Author

Multiple Thread allow to change single variable

Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Hi All,

I am having a small doubt in Threads. In my application, I am creating a ArryList in ClassA, adding 100 different values. Now I am passing this ArrayList to ClassB. Here, creating 'n' number of threads. All the threads are making some chages on the same ArrayList. If one thread made any changes, It should reflect to another.

Can any one Help me for this condition. Thanks.

Regards,
Prabhakaran


Regards,
Prabhakaran.N
Siva Arun
Greenhorn

Joined: Feb 23, 2010
Posts: 28
Try Vector Instead of ArrayList


"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
To expand on what Siva Arun said, that sounds like a synchronisation problem, that changes are made at the same time by your many threads.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Let's move this to Threads and Synchronization.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Thanks Guys..!! I got the result.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Thread allow to change single variable
 
Similar Threads
need clarification on threads
Java thread synchronization problem
How to wait until all threads finishes task?
Instance variables during Threads
Making java program wait for a specific time