| Author |
A thread calling a method on another thread
|
Griff Haldeman
Greenhorn
Joined: Jul 01, 2011
Posts: 5
|
|
Is there a way for Thread 2 to call a method that will go on Thread 1's stack and interrupt whatever Thread 1 is currently doing?
Thread 1: Running happily along
Thread 2: Comes along and calls a method that will go on Thread 1's stack, NOT Thread 2's stack; method runs to completion; Thread 1 resumes what it was doing
Thanks!
|
 |
Luigi Plinge
Ranch Hand
Joined: Jan 06, 2011
Posts: 441
|
|
|
I don't believe there is any notion of threads sharing stacks in Java.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Nope. Was that idea supposed to be a solution to some problem, or was it just a question out of general interest? If there was an actual problem involved, it would be better to just ask about that problem.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
And welcome to the Ranch
It is of course possible for methods running in two threads to call methods on a particular object simultaneously and interfere with each other. Which is why you need synchronisation or similar.
|
 |
 |
|
|
subject: A thread calling a method on another thread
|
|
|