java - how to notify to another thread about a file being modified -


i new java multithreading programming. know can done thread communication don't know how proceed. don't know how 1 thread notify if changes done in file. problem mentioned below.

i have comma separated file in lines written. want 2 threads started main thread. csv file might appended externally/manually. 1 of thread notify second thread if changes done in csv file , second thread read file concurrently line line , perform task.

thanks.

you can use java.nio.file.watchservice purpose.
refer tutorial

from link:-

the watch service api designed applications need notified file change events. suited application, editor or ide, potentially has many open files , needs ensure files synchronized file system. suited application server watches directory, perhaps waiting .jsp or .jar files drop, in order deploy them.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -