菜鸟问题,谢谢请帮忙! Thread aThread = new Thread(new ProcessorThread1());aThread.start(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是详细的代码,刚才说错了,编译能通过,不过运行时出错import java.net.*;import java.io.*;import java.lang.*;import java.util.*; public class ProcessorThread1 implements Runnable { private Thread mTdThread[]; private static int mintThreadCount=0; static int mintWait=0; //空闲线程总数 static int mintBusy=0; //运行线程总数 static int mintCount=0; //数据接受线程总数 static String mstrSubstt=""; static int mintDd; //用于引用ReqUDPPortListener类中要求线程个数的变量 static int mintMid; //用于比较的中间变量 static DataPool mdpPool=ReqUDPPortListener.mdpPool; //用于引用ReqUDPPortListener类中数据池的堆栈 public void threadNew() { mintThreadCount++; mTdThread[mintThreadCount]=new Thread(this); System.out.println("新线程:"+mintThreadCount+"建立"); mintWait++; System.out.println("现有空闲线成数目为:"+mintWait); System.out.println("现有运行状态线程数目为:"+mintBusy); System.out.println("现有各状态线程总数为:"+mintThreadCount); } public void threadStart() { mTdThread[mintThreadCount].start(); System.out.println("线程:"+mintThreadCount+"启动"); mintWait--; mintBusy++; System.out.println("现有空闲线成数目为:"+mintWait); System.out.println("现有运行状态线程数目为:"+mintBusy); System.out.println("现有各状态线程总数为:"+mintThreadCount); } public void threadWait() { } public void threadDestroy() { } public void run() { System.out.println("aaaaaaaaaaa"); } public static void main(String [] arguments) { ProcessorThread1 dd=new ProcessorThread1(); dd.threadStart(); } public class ProcessorThread1 implements Runnable { private Thread mTdThread[]; private static int mintThreadCount=0;public void start () { mTdThread[mintThreadCount]=new Thread(this); mTdThread[mintThreadCount].start(); } public void run() { System.out.println("fsa");}} 建议不要用this,还是写明好一些也方便维护 不写this,写明了,也不行,我刚试过 给你修改后的,可以运行的:public class ProcessorThread1 implements Runnable { private Thread mTdThread[]=new Thread[3];//这里有初始化数组 private static int mintThreadCount=0; public static void main(String[] a){ ProcessorThread1 b=new ProcessorThread1(); b.start(); }public void start () { mTdThread[mintThreadCount]=new Thread(new ProcessorThread1()); mTdThread[mintThreadCount].start(); } public void run() { System.out.println("fsa"); }}记住:数组必须初始化后才能使用,不然出现空指针异常。 上面运行后的输出结果:---------- java ----------fsaNormal TerminationOutput completed (0 sec consumed). 这是我修改过的程序,编译通过了:可是仍然有空指针异常import java.net.*;import java.io.*;import java.lang.*;import java.util.*; public class ProcessorThread1 implements Runnable { private Thread mTdThread[]=new Thread [1000]; private static int mintThreadCount=0; static int mintWait=0; //空闲线程总数 static int mintBusy=0; //运行线程总数 static int mintCount=0; //数据接受线程总数 static String mstrSubstt=""; static int mintDd; //用于引用ReqUDPPortListener类中要求线程个数的变量 static int mintMid; //用于比较的中间变量 static DataPool mdpPool=ReqUDPPortListener.mdpPool; //用于引用ReqUDPPortListener类中数据池的堆栈 public void threadNew() { mintThreadCount++; mTdThread[mintThreadCount]=new Thread(new ProcessorThread1()); System.out.println("新线程:"+mintThreadCount+"建立"); mintWait++; System.out.println("现有空闲线成数目为:"+mintWait); System.out.println("现有运行状态线程数目为:"+mintBusy); System.out.println("现有各状态线程总数为:"+mintThreadCount); } public void start() { mTdThread[mintThreadCount].start(); System.out.println("线程:"+mintThreadCount+"启动"); mintWait--; mintBusy++; System.out.println("现有空闲线成数目为:"+mintWait); System.out.println("现有运行状态线程数目为:"+mintBusy); System.out.println("现有各状态线程总数为:"+mintThreadCount); } public void threadWait() { } public void threadDestroy() { } public void run() { System.out.println("aaaaaaaaaaa"); } public static void main(String [] arguments) { ProcessorThread1 dd=new ProcessorThread1(); dd.start(); } threadStart() 这个函数谁调用的,你的构造函数呢 对不起是public void threadNew() 这个函数谁调用的,你的构造函数呢刚才打错了 to:shanmao(山猫) \wjmmml(笑着悲伤) :谢谢你们,我的问题找到了,谢谢,接分吧 关于正则表达式 一个关于图像显示的问题~为什么我这程序无法显示图像啊,错在哪?? 替换字符串中的$$为$_$,百分感谢 问大家一个问题[参加有分] 存储过程用setString传参数的问题 求问如何抓取谷歌图片搜索的结果 -- GUI的几个问题 -- 我现在是java初级程序员,以后怎么样学习java? Method的调用方法,by reference or by value java 编程软件 intellij idea遇到的问题 小弟以前是学DELPHI的现在想学JAVA,, 问一个简单问题。
import java.net.*;
import java.io.*;
import java.lang.*;
import java.util.*;
public class ProcessorThread1 implements Runnable {
private Thread mTdThread[];
private static int mintThreadCount=0;
static int mintWait=0; //空闲线程总数
static int mintBusy=0; //运行线程总数
static int mintCount=0; //数据接受线程总数
static String mstrSubstt="";
static int mintDd; //用于引用ReqUDPPortListener类中要求线程个数的变量
static int mintMid; //用于比较的中间变量
static DataPool mdpPool=ReqUDPPortListener.mdpPool;
//用于引用ReqUDPPortListener类中数据池的堆栈
public void threadNew()
{
mintThreadCount++;
mTdThread[mintThreadCount]=new Thread(this);
System.out.println("新线程:"+mintThreadCount+"建立");
mintWait++;
System.out.println("现有空闲线成数目为:"+mintWait);
System.out.println("现有运行状态线程数目为:"+mintBusy);
System.out.println("现有各状态线程总数为:"+mintThreadCount);
}
public void threadStart()
{
mTdThread[mintThreadCount].start();
System.out.println("线程:"+mintThreadCount+"启动");
mintWait--;
mintBusy++;
System.out.println("现有空闲线成数目为:"+mintWait);
System.out.println("现有运行状态线程数目为:"+mintBusy);
System.out.println("现有各状态线程总数为:"+mintThreadCount);
}
public void threadWait()
{
}
public void threadDestroy()
{
}
public void run()
{
System.out.println("aaaaaaaaaaa");
}
public static void main(String [] arguments)
{
ProcessorThread1 dd=new ProcessorThread1();
dd.threadStart();
}
private Thread mTdThread[];
private static int mintThreadCount=0;
public void start () {
mTdThread[mintThreadCount]=new Thread(this);
mTdThread[mintThreadCount].start();
}
public void run()
{
System.out.println("fsa");
}
}
public class ProcessorThread1 implements Runnable {
private Thread mTdThread[]=new Thread[3];//这里有初始化数组
private static int mintThreadCount=0;
public static void main(String[] a){
ProcessorThread1 b=new ProcessorThread1();
b.start();
}
public void start () { mTdThread[mintThreadCount]=new Thread(new ProcessorThread1());
mTdThread[mintThreadCount].start();
}
public void run()
{
System.out.println("fsa");
}
}记住:数组必须初始化后才能使用,不然出现空指针异常。
fsa
Normal Termination
Output completed (0 sec consumed).
import java.net.*;
import java.io.*;
import java.lang.*;
import java.util.*;
public class ProcessorThread1 implements Runnable {
private Thread mTdThread[]=new Thread [1000];
private static int mintThreadCount=0;
static int mintWait=0; //空闲线程总数
static int mintBusy=0; //运行线程总数
static int mintCount=0; //数据接受线程总数
static String mstrSubstt="";
static int mintDd; //用于引用ReqUDPPortListener类中要求线程个数的变量
static int mintMid; //用于比较的中间变量
static DataPool mdpPool=ReqUDPPortListener.mdpPool;
//用于引用ReqUDPPortListener类中数据池的堆栈
public void threadNew()
{
mintThreadCount++;
mTdThread[mintThreadCount]=new Thread(new ProcessorThread1());
System.out.println("新线程:"+mintThreadCount+"建立");
mintWait++;
System.out.println("现有空闲线成数目为:"+mintWait);
System.out.println("现有运行状态线程数目为:"+mintBusy);
System.out.println("现有各状态线程总数为:"+mintThreadCount);
}
public void start()
{
mTdThread[mintThreadCount].start();
System.out.println("线程:"+mintThreadCount+"启动");
mintWait--;
mintBusy++;
System.out.println("现有空闲线成数目为:"+mintWait);
System.out.println("现有运行状态线程数目为:"+mintBusy);
System.out.println("现有各状态线程总数为:"+mintThreadCount);
}
public void threadWait()
{
}
public void threadDestroy()
{
}
public void run()
{
System.out.println("aaaaaaaaaaa");
}
public static void main(String [] arguments)
{
ProcessorThread1 dd=new ProcessorThread1();
dd.start();
}
刚才打错了