首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > 高性能WEB开发 >

异常提示: Exception in thread "Thread-0" java.lang.NullPointerException ?

2012-02-27 
错误提示: Exception in thread Thread-0 java.lang.NullPointerException ??大家好 请帮我 看一下 怎么

错误提示: Exception in thread "Thread-0" java.lang.NullPointerException ??
大家好 请帮我 看一下 怎么出这些错误信息 
----------------------------------------- 
Exception in thread "Thread-0" java.lang.NullPointerException 
at flex.testdrive.feed.Feed$FeedThread.run(Feed.java:61) 
------------------------------- 

Java code
package flex.testdrive.feed;import java.util.*;import flex.messaging.MessageBroker;import flex.messaging.messages.AsyncMessage;import flex.messaging.util.UUIDUtils;public class Feed {    private static FeedThread thread;    public Feed() {    }    public static void main(String args[]){        Feed fd = new Feed();        fd.start();                    }    public void start() {        if (thread == null) {            thread = new FeedThread();            thread.start();        }    }    public void stop() {        thread.running = false;        thread = null;    }    public static class FeedThread extends Thread {        public boolean running = true;        public void run() {            MessageBroker msgBroker = MessageBroker.getMessageBroker(null);            String clientID = UUIDUtils.createUUID();            Random random = new Random();            double initialValue = 35;            double currentValue = 35;            double maxChange = initialValue * 0.005;            while (running) {                double change = maxChange - random.nextDouble() * maxChange * 2;                double newValue = currentValue + change;                if (currentValue < initialValue + initialValue * 0.15                        && currentValue > initialValue - initialValue * 0.15) {                    currentValue = newValue;                } else {                    currentValue -= change;                }                AsyncMessage msg = new AsyncMessage();                msg.setDestination("feed");                msg.setClientId(clientID);                msg.setMessageId(UUIDUtils.createUUID());                msg.setTimestamp(System.currentTimeMillis());                msg.setBody(new Double(currentValue));            [color=#FF0000]    msgBroker.routeMessageToService(msg, null); //这个地方出现错误[/color]                   System.out.println("" + currentValue);                try {                    Thread.sleep(300);                } catch (InterruptedException e) {                }            }        }    }}


[解决办法]
建议Debug一下。

热点排行