日期:2014-05-18 浏览次数:20950 次
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.channels.FileLock;
public class ReadAndWriteByLock
{
public static void main(String[] args)
{
Runnable readThread = new Runnable()
{
public void run()
{
File oneFile = new File("allMyWords.txt");
readFileByLock(oneFile);
}
};
Runnable writeThread = new Runnable()
{
public void run()
{