螺纹不';不要在android服务中运行

螺纹不';不要在android服务中运行,android,multithreading,service,Android,Multithreading,Service,我想使用服务进行后台下载,但我无法在我的服务中启动线程。从未调用run方法(我尝试了本地和单独的流程服务) toast不会出现,运行中的断点也不会触发。 我错过了什么吗?你没有开始 new Thread(new DownloadRunnable()).start() 你不能开始线程 new Thread(new DownloadRunnable()).start() 您只创建了线程,其他什么都没有:new thread(new DownloadRunnable());我担心这会让人尴尬。我现

我想使用服务进行后台下载,但我无法在我的服务中启动线程。从未调用run方法(我尝试了本地和单独的流程服务)

toast不会出现,运行中的断点也不会触发。
我错过了什么吗?

你没有开始

new Thread(new DownloadRunnable()).start()

你不能开始线程

new Thread(new DownloadRunnable()).start()

您只创建了线程,其他什么都没有:new thread(new DownloadRunnable());我担心这会让人尴尬。我现在知道了.start()发生了什么,因为它在以前版本的代码中。当创建线程时,IDE应该为此生成警告,该线程没有开始,也没有为变量赋值。您只创建了线程,其他什么都没有:new thread(new DownloadRunnable());我担心这会让人尴尬。我现在知道了.start()发生了什么,因为它在以前版本的代码中。当创建的线程没有开始或变量赋值时,IDE应该为此生成警告。