Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

显示错误为

Exception in thread “main” java.lang.Error: Unresolved compilation problems: 
    Duplicate local variable t1
    The method set() is undefined for the type Thread
    The method get() is undefined for the type Thread
    The method set(String) is undefined for the type Thread
    The method get() is undefined for the type Thread

    at jdbc.TestThreadLocal.main(TestThreadLocal.java:8)

大致意思是:

重复的局部变量t1
对于Thread类型,未定义方法set()
类型Thread的get()方法未定义
类型Thread的方法set(String)未定义
类型Thread的get()方法未定义

 

上图如下:

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

 

然而这是我对着老师的教学视频打的,一字不落,一编译就是这,我在网上复制一样的代码,就不出错。

如下:我把上面t1.set() 改成一个空格都不落下,还是有问题

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

这尼玛真是玄学

我的对着打的就出错,查了很多资料,关机重启的,新建个包或文件

都不管用啊,有会的大佬,麻烦帮我解答一下,万分感谢

上图Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

 不说了,一个是线程问题,回去复习去了。

貌似是ThreadLocal这个类的调用出了问题


暂时放弃了,myeclipse到现在都没破解,手贱,上来接近打开,2017的一个月使用期,啥也没干,这一个月再不学,就费了。

考虑到可能是jdk或者安装环境的问题,到学校考虑刷个系统,考、

package test;

public class JdbcTest {
	public static void main(String[] args) throws Exception {
		final ThreadLocal<String> thr = new ThreadLocal<String>(); 
		
		Thread th = new Thread(){
			 public void run(){
				 thr.set("你好啊 ");
				 System.out.println(" の :"+thr.get());
			 }
			};
		th.start();
		Thread.sleep(2000);
		Thread th22 = new Thread(){
			 public void run(){
				 thr.set("非常不好! ");
				 System.out.println(" w :"+thr.get());
			 }
			};
		th22.start();
	}
}

不重名的情况勉强实现这个功能

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/114780.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号