Can I do multi threading with ThreadLocal with SSH?

30 views
Skip to first unread message

nat...@capsoff.com

unread,
Jul 8, 2018, 10:31:08 PM7/8/18
to Yet another Expect for Java
I was hoping that maybe by using ThreadLocal I could do multi threading. Can you for see any issue? Many thanks for any type of answer.

Alexey Gavrilov

unread,
Jul 24, 2018, 8:01:46 AM7/24/18
to nat...@capsoff.com, Yet another Expect for Java
The should not be any issue making an instance of ExpectIt a thread local variable and using in multithreaded environment

> 9. jul. 2018 kl. 04:31 skrev nat...@capsoff.com:
>
> I was hoping that maybe by using ThreadLocal I could do multi threading. Can you for see any issue? Many thanks for any type of answer.
>
> --
> You received this message because you are subscribed to the Google Groups "Yet another Expect for Java" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to java-expecti...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

nat...@capsoff.com

unread,
Jul 24, 2018, 10:26:52 PM7/24/18
to Yet another Expect for Java
Thank you

nat...@capsoff.com

unread,
Jul 26, 2018, 5:40:38 PM7/26/18
to Yet another Expect for Java
It worked!

ping is my class where all the expect stuff is happening....

ThreadLocal<ping> pingTL = new ThreadLocal<>();

String IP;

public worker(String ip) {
this.IP = ip;
}

@Override
public void run() {
// TODO Auto-generated method stub

ping ping = new ping(IP);
pingTL.set(ping);
pingTL.get().pingIP();

}

Reply all
Reply to author
Forward
0 new messages