什么把字符串转化成为字符串数组?? 本帖最后由 dicmo 于 2010-03-31 19:51:52 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Main { public static void main(String[] args) throws MalformedURLException, IOException { String str = "什么把字符串转化成为字符串数组??"; char[] ct = str.toCharArray();//符串转化成为字符串数组 final Gon g = new Gon(ct); for (int i = 0; i < 10; i++) { new Thread(new Runnable() { public void run() { while (g.hasNext()) { char c = g.getC(); if (g.hasNext()) { System.out.println(Thread.currentThread().getName() + ":" + c); } } } }).start(); } }}class Gon { char[] c; int po, cou; Gon(char[] ch) { c = ch; } synchronized char getC() { try { Thread.sleep(1000);//停1000毫秒 } catch (InterruptedException ex) { } po++; if (po > c.length) { return '\0'; } return c[cou++]; } boolean hasNext() { return po <= c.length; }} java中有关对象数组的问题! 请问DispatchAction这个类有什么用,都有什么方法? xml问题,难倒没人会,我发了还多帖子了。都是无满意结贴。 如何在一个数组中提取6或者7个数和几乎相等 两个基础问题:1:java.sql.Date 2:ResultSet 请教 求救 大哥快来回答我的问题(tomcat 的设置和它的hello 程序的实现)beyond_xiruo .class后缀的文件能不能看到其源代码 这本书怎么样,大侠帮忙看一下! 谁能解释一下JNDI,好象比较抽象,不好理解! JComboBox第一次点击没反应呢? 计算圆周率
String str = "什么把字符串转化成为字符串数组??";
char[] ct = str.toCharArray();//符串转化成为字符串数组
final Gon g = new Gon(ct);
for (int i = 0; i < 10; i++) {
new Thread(new Runnable() { public void run() {
while (g.hasNext()) {
char c = g.getC();
if (g.hasNext()) {
System.out.println(Thread.currentThread().getName() + ":" + c);
}
}
}
}).start();
}
}
}class Gon { char[] c;
int po, cou; Gon(char[] ch) {
c = ch;
} synchronized char getC() {
try {
Thread.sleep(1000);//停1000毫秒
} catch (InterruptedException ex) {
}
po++;
if (po > c.length) {
return '\0';
}
return c[cou++];
} boolean hasNext() {
return po <= c.length;
}
}