Scalable
Scalable

Reputation: 1681

Java Console Application Locked

Java is not my main programming language so my expertise are generally limited in this area.

Scenario

This app is supposed to execute for indefinitely like a service or daemon. Its main purpose is to process some rows in DB as they are inserted by some other process.

The app at times Spits out log messages through System.out.println. It also uses some other log files. I was earlier using log4j but that is disabled for the moment.

Also I am running this in Windows Server environment, if that helps. I cant use linux for now.

Problem

The problem is that, on rare occasions, I find the application in staging/prod env becomes locked or does not seem to process any DB rows further. After I press enter a few times on screen it moves ahead and start processing as usual. This is strange because I am not expecting any input from the user. Any input the app has is either from command line or from DB.

Also I know for sure that its not a DB issue. The app is not waiting for any table lock. It may have to do with some file locking or System.out stream being locked. The later I did not think of possibility until I see that some keystroke on screen 'wakes' the application.

So I am wondering if someone may point me in a direction where I can debug this further.

Upvotes: 3

Views: 684

Answers (2)

developer learn999
developer learn999

Reputation: 395

this is the way to do it go tp properties and un-check : "quick edit mode" remove quick edit mode checkbox

Upvotes: 2

Mike Nakis
Mike Nakis

Reputation: 62130

Microsoft in all its infinite wisdom has made the console window in such a way that it allows you to select a rectangular area of characters with the mouse. So far so good.

And supposedly in order to make it easier for the user to select text while text may be scrolling, they (in their infinite wisdom) freeze the process hosted by the terminal window if it attempts to emit text while you are selecting text. (*)

And it just so happens that if you do as little as click a console window with the mouse, they (in their infinite wisdom) put the window in text selection mode, as witnessed by the presence of a little white square.

Which is very unfortunate, because clicking on a window is what we also do in order to simply bring the window to the foreground. But there is a huge gotcha here: if the console window was not already on the foreground, then clicking it brings it to the foreground. But if the console window was already on the foreground, then clicking it enters selection mode. (And of course most people rarely know, or care, or want to be bothered, with whether the window is already on the foreground or not.)

So, to conclude: try not clicking your window. Click only the caption if you have to. If you do accidentally click on the window, then press [Enter] or click again to make the little white selection rectangle go away.

Because for as long as the little white selection rectangle is there, your program is frozen.


(*) Now, they could have easily frozen the display of the window while selecting without freezing the process; they could have made it so that the output of the process keeps being buffered, and then dumped on the screen once selection is done, but I guess they were too busy with their plans for world domination to get around to fixing this. I cannot even begin to think how much time (= money) must have been wasted all over the world so far due to microsoft console windows sitting idle in selection mode while people are under the impression that they are crunching data.

Upvotes: 4

Related Questions