public void threadPreempt() {

		int n = getMenuCount();
		if (n == 0)
			return;

		PopupMenuListener listener = new PopupMenuListener() {

			public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
				if (model == null)
					return;
				if (model.getJob() == null)
					return;
				if (model.getJob().isStopped())
					return;
				model.getJob().stop();
			}

			public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
				if (model == null)
					return;
				if (model.getJob() == null)
					return;
				if (model.getJob().isStopped() && !model.getJob().isTurnedOff())
					model.getJob().start();
			}

			public void popupMenuCanceled(PopupMenuEvent e) {
			}

		};

		for (int i = 0; i < n; i++)
			getMenu(i).getPopupMenu().addPopupMenuListener(listener);

	}