1。写2个线程对j加1,2个线程对j减1

public class ThreadTest {
 public int j;
 public static void main(String[] args) {
  ThreadTest t = new ThreadTest();
  D d1 = new D(t);
  D d2 = new D(t);
  E e1 = new E(t);
  E e2 = new E(t);
  d1.run();
  d2.run();
  e1.run();
  e2.run();
 }

}
class D implements Runnable {
 
 private ThreadTest t;
 public D(ThreadTest t){
  this.t = t;
 }
 public void run() {
  t.j –;
//  System.out.println(t.j);
 }
}
class E implements Runnable{
 private ThreadTest t;
 public E(ThreadTest t){
  this.t = t;
 }
 public void run(){
  t.j ++;
//  System.out.println(t.j);
 }
}

 

===============================================

2.写一个单例

//懒汉式public class Singleton {

public static Singleton instance = null; private Singleton() {}

public static Singleton getInstance() {

if(instance == null)

instance = new Singleton();

return instance; }}

//饿汉式public class Singleton {

public static Singleton instance = new Singleton();

private Singleton() {}

public static Singleton getInstance() { return instance; }}

 

 

3.读取一个文件,将每一行存入linkedlist中,然后倒序取出显示

public class FileReader {
 public static void main(String[] args) {
  File f = new File("1.txt");
  LinkedList<String> list = new LinkedList<String>();
  try {
   java.io.FileReader fr = new java.io.FileReader(f);
   java.io.BufferedReader br = new BufferedReader(fr);
   String s  = null;
   try {
    while ((s = br.readLine())!= null){
     list.add(s);
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  } catch (FileNotFoundException e) {
   
   e.printStackTrace();
  }
  
  for(int i = 0 ; i < list.size(); i++){
   System.out.println(list.get(list.size() – i -1));
  }
  
 }
}

==============================

数据库

学生表(Student)

name   course    score

张三      英语       81

张三       数学      90

。。。。。

问题一:用一条sql读出每门课程分数都高于80分的学生name