wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 37900
    
  22
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: 19649
    
  18

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.
 
Don't get me started about those stupid light bulbs.
 
subject: Multiple Thread allow to change single variable
 
Similar Threads
Making java program wait for a specific time
need clarification on threads
Instance variables during Threads
Java thread synchronization problem
How to wait until all threads finishes task?