Threads



I'm having some trouble understanding how to set up a thread to pause
execution when some other thread meets some condition. I'm using a
base class and then at least 2 classes that extends Thread. The
threads don't share any data among each other, just between the thread
and the base class. The baseClass just starts the other threads and
outputs information to the screen. For some background this is a
robotics project so the threads are moving the robot and reading
data. If certain threads aren't paused they will conflict with each
other.


Here is a basic view of the classes:

public class baseClass
{
thread1 thread1Obj = new thread1();
thread2 thread2Obj = new thread2();
....

void upDateScreen()
{
thread1Obj.start();
thread2Obj.start();

while(true)
{
//output things to screen
}
}
}

class thread1 extends Thread
{
int x = 0;


void run()
{ //At the present moment, everything inside the run() is in an
infinite loop. This can change if necessary

//Read x in from a sensor
if(x<10)
//Pause all other threads so this one can do what it
needs to do
...
}
}

class thread2 extends Thread
{
void run()
{
...
}
}

How do I set it up so that thread2 is paused while thread1 is doing
something important?

Thanks

.



Relevant Pages

  • Re: inhibit compiler warning C4624 for a class hierarchy
    ... I'd really like to just pretend that the dynamic type is the base class. ... ** Carries a request or notification and any associated parameters. ... static void* operator new ... struct PNPEXPORT IConcurrentOperations::OpNotification abstract: public ...
    (microsoft.public.vc.language)
  • Re: Hooking automation object Events
    ... The next few lines of my post show the procedure SelectionChange: ... _PowerPCBDocEvents = dispinterface; ... void PowerPCBSink::OnFinalRelease ... // object before calling the base class. ...
    (comp.lang.pascal.delphi.misc)
  • RE: Protected keyword
    ... Only the Employee class internally can see the base class RaiseEvent method. ... public void HoldBreath{ ... a child that inherits from it so as to be able to call the protected method ...
    (microsoft.public.dotnet.languages.csharp)
  • Type of base pointer
    ... public override void Test() ... base class for B is A not A" ... I have a virtual function called Testin class A. Also i have class B ... As well base object doesn't have method OldTest(). ...
    (microsoft.public.dotnet.framework)
  • synchronized method
    ... wil create n instances of Notifier. ... class WaitNotify extends Thread{ ... public synchronized void run{ ...
    (comp.lang.java.help)