Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to share information between two Threads?  RSS feed

 
jacob deiter
Ranch Hand
Posts: 587
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two threads and want to share information between them

Please explain what are the possible way?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are thinking about the problem backwards (or possibly upside-down.)

Information (variables) has a home in one or more Java classes, NOT in a Thread. A Thread just executes a run method.

Any number of Threads can be executing the run method in a single instance of a class so they all "see" the same variables.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!