Monitor file to find which thread is modifying file

I want to find which java thread is modifying file. If anybody know tool or know how we can monitor and get thread name please share.

Thanks.

Answers


I am not sure why exactly you need this information but i beleive there are two ways.

First way is in your java code when you create a thread , create it with a name. There are constructors & method available in Thread class to do the same. If you have a good logging in your project then you can log the thread name who enters the code to modify the file.

Second way is again dependent on having a thread with the name. You can use a java profiler to find out what threads are doing at a point in time. Although it will be too tough if threads are modifying the file too quickly. But if you are trying to find a problem of slow modification of file by a thread then profiler may give you the hint.

Hope it helps!


if the file modification is a code that you wrote, you can use before the modification:

Thread.currentThread().getName();
Thread.currentThread().getId();

and youl get the name and id of the thread


Need Your Help

How to Click on a Button which has an ID Button3 when it is inactive and it changes to Button1 when it is active , using Autoit

autoit

I am using Autoit to Automate our qa installer. I am new to this. I am stuck at a point. The Scenario is explained Below.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.