Revert the changes to shell tui that make it stoppable without user input from system.in - The solution is working fine on *x but doesn't on windows.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@650237 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java b/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
index 1b94a62..b8d025b 100644
--- a/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
+++ b/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
@@ -83,13 +83,10 @@
// since one might already be available.
initializeService();
- synchronized (this)
- {
- // Start impl thread.
- m_thread = new Thread(
- m_runnable = new ShellTuiRunnable(),
- "Felix Shell TUI");
- }
+ // Start impl thread.
+ m_thread = new Thread(
+ m_runnable = new ShellTuiRunnable(),
+ "Felix Shell TUI");
m_thread.start();
}
@@ -110,19 +107,16 @@
public void stop(BundleContext context)
{
- synchronized (this)
+ if (m_runnable != null)
{
- if (m_runnable != null)
- {
- m_runnable.stop();
- m_thread.interrupt();
- }
+ m_runnable.stop();
+ m_thread.interrupt();
}
}
private class ShellTuiRunnable implements Runnable
{
- private volatile boolean stop = false;
+ private boolean stop = false;
public void stop()
{
@@ -133,22 +127,15 @@
{
String line = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+
while (!stop)
{
System.out.print("-> ");
try
{
- while (!in.ready())
- {
- Thread.sleep(20);
- }
line = in.readLine();
}
- catch (InterruptedException ex)
- {
- continue;
- }
catch (IOException ex)
{
System.err.println("Could not read input, please try again.");
@@ -188,4 +175,4 @@
}
}
}
-}
+}
\ No newline at end of file