Search Results

Search found 6 results on 1 pages for 'wizztjh'.

Page 1/1 | 1 

  • how to get Celsius as output from LM335Z with arduino?

    - by wizztjh
    the firstsensor is my lm335z output. int firstSensor = 0; int secondSensor = 0; int thirdSensor = 0; int inByte = 0; void setup() { Serial.begin(9600); establishContact(); // send a byte to establish contact until receiver responds } void loop() { if (Serial.available() > 0) { inByte = Serial.read(); firstSensor = analogRead(0); delay(10); secondSensor = analogRead(1); thirdSensor = analogRead(2); Serial.print(firstSensor, DEC); Serial.print(","); Serial.print(secondSensor, DEC); Serial.print(","); Serial.println(thirdSensor, DEC); } } void establishContact() { }

    Read the article

  • how to restart a Thread?

    - by wizztjh
    It is a RMI Server object , so many sethumanActivity() might be run , how do i make sure the previous changeToFalse thread will be stop or halt before the new changeToFalse run? t. interrupt ? Basically when sethumanActivity() is invoke , the humanActivity will be set to true , but a thread will be run to set it back to false. But I am thinking for how to disable or kill the thread when another sethumanActivity() invoked? public class VitaminDEngine implements VitaminD { public boolean humanActivity = false; changeToFalse cf = new changeToFalse(); Thread t = new Thread(cf); private class changeToFalse implements Runnable{ @Override public void run() { try { Thread.sleep(4000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } humanActivity = false; } } @Override public void sethumanActivity() throws RemoteException { // TODO Auto-generated method stub humanActivity = true; t.start(); } public boolean gethumanActivity() throws RemoteException { // TODO Auto-generated method stub return humanActivity; } } Edited after the help of SOer package smartOfficeJava; import java.rmi.RemoteException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class VitaminDEngine implements VitaminD { public volatile boolean humanActivity = false; changeToFalse cf = new changeToFalse(); ExecutorService service = Executors.newSingleThreadExecutor(); private class changeToFalse implements Runnable{ @Override public void run() { try { Thread.sleep(4000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } humanActivity = false; } } @Override public synchronized void sethumanActivity() throws RemoteException { humanActivity = true; service.submit(cf); } public synchronized boolean gethumanActivity() throws RemoteException { return humanActivity; } }

    Read the article

  • how to implement a callback in runnable to update other swing class

    - by wizztjh
    I have a thread like this public class SMS { class Read implements Runnable { Read(){ Thread th = new Thread(this); th.start(); } @Override public void run() { // TODO Auto-generated method stub while (true){ Variant SMSAPIReturnValue = SMSAPIJava.invoke("ReadSMS"); if (SMSAPIReturnValue.getBoolean()){ String InNumber = SMSAPIJava.getPropertyAsString("MN"); String InMessage = SMSAPIJava.getPropertyAsString("MSG"); } } } } } How do I update the message to another GUI class in the same package(I understand how to put nested class to another package ....). Should I implement a callback function in SMS class? But how? Or should I pass in the Jlabel into the class?

    Read the article

1