I declared my synchronized view as: Set tset = Collections.synchronizedSet(new TreeSet(new RectComparator()));. I created a thread class as: private class AddThread implements Runnable { ... }. Inside the thread constructor, I'm passing a LinkedList and a Set as parameters e.g., public AddThread (LinkedList list, Set set) { ... }. When I tried to create a thread as: Thread bthread = new Thread(new AddThread(list, tset)); I was getting the following error on compilation time: C:\..\Demo.java:83: non-static variable this cannot be referenced from a static context Thread bthread = new Thread(new AddThread(list,
tset));
^
Does the non-static variable 'this' refers to 'list' or to the Demo (class that contains the main())? Why would the variable 'list' cannot be reference from a static context? My linked list declaration is inside the main. Why is it considering the list as non-static if it was declared within the main? Eventhough I made my List and Set declarations private static..., I was still getting the same compiler message. Any help or suggestions are greatly appreciated. Thanks.
tset));
^
Does the non-static variable 'this' refers to 'list' or to the Demo (class that contains the main())? Why would the variable 'list' cannot be reference from a static context? My linked list declaration is inside the main. Why is it considering the list as non-static if it was declared within the main? Eventhough I made my List and Set declarations private static..., I was still getting the same compiler message. Any help or suggestions are greatly appreciated. Thanks.