This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Thread allow to change single variable

 
Natesan Prabhakaran
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Siva Arun
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Vector Instead of ArrayList
 
Campbell Ritchie
Sheriff
Posts: 48394
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's move this to Threads and Synchronization.
 
Natesan Prabhakaran
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys..!! I got the result.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic