| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 663 人关注过本帖
标题:这题目没有看明白!
取消只看楼主 加入收藏
yynn
Rank: 1
等 级:新手上路
帖 子:279
专家分:0
注 册:2005-11-4
收藏
 问题点数:0 回复次数:4 
这题目没有看明白!
write a program that shares an integer array between 2 separate thread. each thread is given a segment of the array to use and may not write outside its given segment. one of the thread should initializeits values to random number in the rang 1..100 and the other thread should toss a coin N times and record the result of each toss( n equals the segment sive ).the main program should wait for the threads to finish and print the values of the array前面是要两个线程吧数组分成两半,之后又要跑硬币,随即数了!
搜索更多相关主题的帖子: separate between outside thread number 
2007-10-16 05:57
yynn
Rank: 1
等 级:新手上路
帖 子:279
专家分:0
注 册:2005-11-4
收藏
得分:0 

class RandomNumber implements Runnable{
private int n[]=new n[50];
Random r = new Random();
int b = r.nextInt(100);
public void run(){
for(int j=0 ; j<100; j++){
System.out.println(""+n[]);
try{
sleep(100);
}catch(InterruptedException e){}
}
}

}

class Toss implements Runnable{
private int m[] = new m[50];
Random s = new Random();
int a = s.nextInt(2);
public void run(){
for(int j=0 ; j<100; j++){
System.out.println(""+n[j]);
try{
sleep(100);
}catch(InterruptedException e){}
}
}
}

class Q1 {
public static void main(String args[]){
Runnable c1 = new RandomNumber(50);
Runnable c2 = new Toss(50);
new Thread(c1).start();
new Thread(c2).start();
}
}


2007-10-18 01:52
yynn
Rank: 1
等 级:新手上路
帖 子:279
专家分:0
注 册:2005-11-4
收藏
得分:0 
我这样编写错误很多有没有人帮我修改一下啊!本事菜鸟,刚学,但是以上来就碰上thread估计有一堆奇怪的错误!请大师指点了!

2007-10-18 01:53
yynn
Rank: 1
等 级:新手上路
帖 子:279
专家分:0
注 册:2005-11-4
收藏
得分:0 

如果这样的话貌似不能访问了,是private私有的!


2007-10-18 17:26
yynn
Rank: 1
等 级:新手上路
帖 子:279
专家分:0
注 册:2005-11-4
收藏
得分:0 
感觉题目理解是不是一个数组分一半,然后先初始化一半数组,然后跑硬币猜数组!

2007-10-19 00:55
快速回复:这题目没有看明白!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016783 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved