Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97773

How do you share strings between methods and threads?

$
0
0

I'm currently getting data from my clipboard in string form using one method however I need to access this information from another method running on a different thread, I've done some research and come across volatile strings but I am not quite sure how to implement them in my code, this is the basics of my code:

public class MobileSite {
public MobileSite(){
Thread thread = new Thread1(() -> {
         try {
             method1();
         } catch (Exception botFailed) {
              System.out.println("Bot Failed");

            }

    });

Thread thread = new Thread2(() -> {
         try {
             method2();
         } catch (Exception botFailed) {
              System.out.println("Bot Failed");

            }

    });


    thread1.start();
    thread2.start();

method 1 gets the data and method 2 needs to use that data being in string format if anyone has any suggestions they would be much appreciated


Viewing all articles
Browse latest Browse all 97773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>