高分悬赏:fedora 13修改为上海交大的源老是出现问题,如何解决???<详情见补充说明>

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高分悬赏:fedora 13修改为上海交大的源老是出现问题,如何解决???<详情见补充说明>相关的知识,希望对你有一定的参考价值。

配置文件sjtu.repo:
[Fedora-ftp.sjtu.edu.cn]
name=Fedora 13 – i386
baseurl=http://ftp.sjtu.edu.cn/fedora/linux/releases/13/Fedora/i386/os/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
[Everything-ftp.sjtu.edu.cn]
name=Everything 13 – i386
baseurl=http://ftp.sjtu.edu.cn/fedora/linux/releases/13/Everything/i386/os/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
[updates-ftp.sjtu.edu.cn]
name=Fedora updates
baseurl=http://ftp.sjtu.edu.cn/fedora/linux/updates/13/i386/
enabled=1
gpgcheck=0
使用yum clean all
yum makecache后结果如下:
已加载插件:presto, refresh-packagekit
Everything-ftp.sjtu.edu.cn | 4.3 kB 00:00
Everything-ftp.sjtu.edu.cn/filelists_db | 16 MB 00:02
Everything-ftp.sjtu.edu.cn/prestodelta | 414 B 00:00
Everything-ftp.sjtu.edu.cn/primary_db | 10 MB 00:01
Everything-ftp.sjtu.edu.cn/other_db | 5.9 MB 00:00
Everything-ftp.sjtu.edu.cn/group_gz | 389 kB 00:00
Fedora-ftp.sjtu.edu.cn | 4.0 kB 00:00
http://ftp.sjtu.edu.cn/fedora/linux/releases/13/Fedora/i386/os/repodata/27241b0525fd7af48e7eb3c83388b2b2a981e72ac5e534846255394c0826fc95-filelists.sqlite.bz2: [Errno 14] HTTP Error 404 : http://ftp.sjtu.edu.cn/fedora/linux/releases/13/Fedora/i386/os/repodata/27241b0525fd7af48e7eb3c83388b2b2a981e72ac5e534846255394c0826fc95-filelists.sqlite.bz2
尝试其他镜像。
错误:Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again

如何解决???如能解决加分。。。。

参考技术A 大学的ftp一般是只针对内部用户的,校外的ip可能会被拒绝访问的。最好还是直接用lupaworld上面的源,那些是肯定能下载的。 参考技术B 这两天交大源有问题,更新不了本回答被提问者采纳 参考技术C 大概意思是源已经出现了问题 恩 我只知道那么多了 参考技术D 我看不懂您提的问题!希望体谅我对你的问题的答案 第5个回答  2010-06-10 hanyiying cha

java 多线程 同时操作一个变量 高分悬赏

高分悬赏,追加分。
问题描述
我需要两个线程访问同一个List。
一个线程不停的往List中add数据。
一个线程往外get数据,get一条,remove一条。

怎样写:(等待高手改造)
public class Test

public static List list = new ArrayList();

public static void main(String[] args)
myThreadClass1 thread1 = new myThreadClass1();
myThreadClass2 thread2 = new myThreadClass2();
Thread t1 = new Thread(thread1);
Thread t2 = new Thread(thread2);
t1.start();
t2.start();



class myThreadClass1 implements Runnable
public void run()
while(1 == 1)
Test.list.add("123");




class myThreadClass2 implements Runnable
public void run()
if(Test.list.size() > 0)
for(Object ss:Test.list)
System.out.println(ss);
Test.list.remove(ss);



ArrayList不是线程安全的 所以 synchronized 必须有 这一点是关键,其他的都是浮云。还有 两个线程sleep一会更好 否则 这个跟死循环一样了 机器受不了啊!。
public class Test

public static List<String> list = new ArrayList<String>();

public static void main(String[] args)
myThreadClass1 thread1 = new myThreadClass1();
myThreadClass2 thread2 = new myThreadClass2();
Thread t1 = new Thread(thread1);
Thread t2 = new Thread(thread2);
t1.start();
t2.start();



class myThreadClass1 implements Runnable
public void run()
while (true) // 这就不要写1 ==1 了
synchronized (Test.class)
System.out.println("add!!!!");
Test.list.add("123");

try
Thread.sleep(100);
catch (InterruptedException e)
// TODO Auto-generated catch block
e.printStackTrace();





class myThreadClass2 implements Runnable
public void run()
while (true)
synchronized (Test.class)
Iterator it = Test.list.iterator();
// 循环里remove会出冲突异常的
List list2 = new ArrayList();
while (it.hasNext())
Object obj = it.next();
System.out.println("remove:" + obj);
list2.add(obj);

// you can do anything with list2
// avoid java.util.ConcurrentModificationException
Test.list.clear();

try
Thread.sleep(100);
catch (InterruptedException e)
// TODO Auto-generated catch block
e.printStackTrace();



参考技术A 前面的回答我都看了一下,都存在问题。

下面我对你的代码进行了修改,如果有问题,请回复。
需要对list进行同步,保证只有一个线程在操作list。
class myThreadClass1 implements Runnable
public void run()
while(1 == 1)
synchronized (Test.list)
Test.list.add("123");

Thread.yield(); // 别让他老是占着CPU啊




在向外取的时候,不允许别人向里加,所以需要同步list。
class myThreadClass2 implements Runnable
public void run()
while (true)
synchronized (Test.list)
if (!Test.list.isEmpty())
String item = Test.list.get(0);
System.out.println(item);
Test.list.remove(0);


Thread.yield(); // 别让他老是占着CPU啊

参考技术B public class ListThread

static int n = 0;

public static void main(String[] args)
final List<String> list = new ArrayList<String>();
new Thread(new Runnable()

public void run()
while (true)
String str = "add" + n;
list.add(str);
System.out.println("add :" + str);
n++;
try
Thread.sleep(10);
catch (InterruptedException ex)
Logger.getLogger(ListThread.class.getName()).log(Level.SEVERE, null, ex);



).start();
new Thread(new Runnable()

public void run()
while (true)
if (!list.isEmpty())
try
Thread.sleep(10);
catch (InterruptedException ex)
Logger.getLogger(ListThread.class.getName()).log(Level.SEVERE, null, ex);

String str = list.remove(list.size() - 1);
System.out.println("remove :" + str);
n--;



).start();
try
Thread.sleep(100000);
catch (InterruptedException ex)
Logger.getLogger(ListThread.class.getName()).log(Level.SEVERE, null, ex);



同步不是关键,因为你对list的操作都是原子操作,在这个添加、删除过程是不会被其他线程打断超过的,所谓的同步其实是对可能被人打断的动作进行同步,就是说你在提交数据过程如果你这个过程一直是连续的那就没必要同步,但是如果你在提交过程中需要让出cpu,交给其他线程那就要同步,而且必须同步。你说的这种都是原子动作,只是当动作完毕之后才会让人家删除,所以不会有线程问题。
还有一点对于list的操作能够使用get set 就不要使用foreach来操作。foreach要求在遍历过程中不能删除、添加list。推荐使用for循环来遍历list,这样是要关注索引就可以了。
参考技术C public class Test

public static List list = new ArrayList();

public static void main(String[] args)
Test tt = new Test();
myThreadClass1 thread1 = tt.new myThreadClass1();
myThreadClass2 thread2 = tt.new myThreadClass2();
Thread t1 = new Thread(thread1);
Thread t2 = new Thread(thread2);
t1.start();
t2.start();


private synchronized Object getList(int index)
return list.get(index);


private synchronized List getLists()
return list;


private synchronized void setList(Object obj)
Test.list.add(obj);


private synchronized void removeList(int index)
Test.list.remove(index);


class myThreadClass1 implements Runnable
public void run()
int i = 0;
while (1==1)
i++;
setList("第一个------>" + i);
System.out.println("第一个------>" + i);




class myThreadClass2 implements Runnable
public void run()
while(1==1)
if(list.size() > 0)
for(int i = 0; i < getLists().size() ; i++)
System.out.println("移除———————>"+getList(i));
removeList(i);

else
try
Thread.sleep(100);
catch (InterruptedException e)
// TODO Auto-generated catch block
e.printStackTrace();







本回答被提问者采纳
参考技术D import java.util.ArrayList;
import java.util.List;

public class Test


public static List<String> list = new ArrayList<String>();

public static void main(String[] args)

myThreadClass1 thread1 = new myThreadClass1();
myThreadClass2 thread2 = new myThreadClass2();
Thread t1 = new Thread(thread1);
Thread t2 = new Thread(thread2);
t1.start();
t2.start();



class myThreadClass1 implements Runnable

public void run()

int num = 0;
while(true)

num ++;
String data = num+"";
System.out.println("添加="+data);
Test.list.add(data);
try
Thread.sleep(80);
catch (InterruptedException e)
// TODO Auto-generated catch block
e.printStackTrace();





class myThreadClass2 implements Runnable

public void run()

while(true)

if(Test.list.size() > 0)

System.out.println("删除="+Test.list.get(0));
Test.list.remove(0);

else

System.out.println("线程2 暂无数据");

try

Thread.sleep(80);
catch (InterruptedException e)
// TODO Auto-generated catch block
e.printStackTrace();




可以看输出 同意改变2个线程 比如1号线程40 2号80就会出现添加2个删除1个 反过来就会出现添加一个 删除一个 还有一个没有数据的提示
我是aa88567414换号了

以上是关于高分悬赏:fedora 13修改为上海交大的源老是出现问题,如何解决???<详情见补充说明>的主要内容,如果未能解决你的问题,请参考以下文章

急!【高分悬赏】北交大(单片机实验控制)课的实验一(回答得好有追加) 我只要实验程序和思考问题的答案

C语言高手进(高分悬赏)

写个脚本使用perl或shell对比oracle表数据,急啊,高分悬赏!

高分悬赏!关于软件

fedora 9的yum源问题

高分悬赏C语言题目!!!