Thread is not Thread? is not muti tasking?

hi all, plz help for my thread problem
i have written a swing class with inplememnt a mouselistener
and in my swing class there is a JButton
and i have overload the
mousepressed and mouserelease ..etc method
such that:
public void mouseReleased(MouseEvent e) {
System.out.println("mouse Released");
public void mousePressed(MouseEvent e) {
System.out.println("mouse pressed");
when i press the Jbutton.
it print out
mouse pressed
mouse released
mouse clicked
the problem appear when i add a thread to mousepressed function
such that:
public void mousePressed(MouseEvent e) {
System.out.println("mouse pressed");
mythread = new myOwnThread();
mythread.start();
System.out.println("thread Created");
public void mouseReleased(MouseEvent e) {
System.out.println("mouse Released");
if(mythread.isAlive())
mythread.destroy();
mythread is class that with a forever looping. i wanna to kill mythread
when the user release the mouse button.
however, after the mythread is added. the mouselistener can't get the mouseReleased event. and i can't kill mythread by detect release event.
can anyone help me?? urgent.
yours,
Terry Chan.

What you really want to know is how to stop your "MyThread" class. This is one of the most commonly asked questions in this forum so I will try to explain my view thoroughly.
You cannot automagically stop a Thread. The Thread class has a stop method but it is deprecated -- don't use it. The only official way to stop a thread, therefore, is for the "run()" method to exit.
As a result, you need to add functionality to your thread class to make the run method exit. A good way to do this is to add a boolean member variable to your Thread class. Then, sometime in each loop of your run method, check to see if you should stop and break out of the loop.
Here is one possible example, there are any number of other ways to accomplish the same thing:
public class MyThread extends Thread {
  private boolean endThread = false;
  private final Object END_MUTEX = new Object();
  public void setEndThread(boolean endThread) {
    synchronized(END_MUTEX) {
      this.endThread = endThread;
  public boolean getEndThread() {
    synchronized(END_MUTEX) {
      return this.endThread;
  public void run() {
    while(true) {
      if (getEndThread())
        break;
      else {
         // do stuff
      Thread.yield();
}

Similar Messages

  • Notes and tasks have disappeare​d

    i had preoblems with my curve 8520 last night resulting me to reinstall the OS. I luckily used blackberry protect to back everything up. However all of the games have disapeared that came with the phone originaly and the notes and task apps have disappeared. I am not too worried about the games but I had a large amount of notes and tasks that I need to get back is there anyone who can help???

    Look for you notes app as Memos on the device.
    If you don't see it...
    1. On your homescreen, press the Menu key > SHOW ALL, so that SHOW ALL is checked.
    2. Look in EACH folder on your device... Applications, Instant Messengers, Downloads, etc.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Could not create task file

    We are installing SAP R3 4.7 sr1 on Linux SuSE SLES9, 32/bit.
    Problem: During the installation of DI, phase Database Load (Pst Processing), installation stopped , and in the log file said
    Could not create task file tmp/sapinst_instdir/.../SAPREPOS.TSK
    Anyone with the similar problem? Solution?
    Best regards,
    Igor Kokai

    Hello:
    I do not know exactly what of the following elements contributed to fix the problem, but
    following is the list of changes we did in a 3rd try to install R/3 on Sun Solaris.
    1.  Get latest SAPINST.
    2.  Use a different installation directory, which is permitted by the use os a new SAPINST.  We used something outside /tmp, which is used by default by the SAPINST that comes with the CDs.
    3.  Delete the whole installation and start again, because by just using SAPINST in the middle of the installation, the problem was not fixed.
    4.  Change the SID from DEN to DE1.
    5.  There was an answer in sdn about the problem telling a linux user to use another environment variable that was for HP-UX, but since it was suggested for them, we took it, just in case. That was also done in the middle of the installation when the problem was happening, but did not fix the problem.
    6. We did not install the oracle patch 9.2.0.7 because the patch is the one that looks for a bunch of sun patches, that although we already had them, since the error we were getting was oracle related, it was decided not to do that for now.
    7.  Smile and go ahead without desperation.
    Regards,
    Juan

  • Could not create task or type of type: validateTask

    While writing a master Ant script which calls the build.xml of individual BPEL processes, the following exception is thrown.
    validateTask:
    [echo]
    [echo] -------------------------------------------------------------
    [echo] | Validating workflow
    [echo] -------------------------------------------------------------
    [echo]
    <process name>: The following error occurred while executing this line:
    <build file>:210: The following error occurred while executing this line:
    <build file>:49: Could not create task or type of type: validateTask.
    Ant could not find the task or a class this task relies upon.
    I have tried the following options;
    1.) The same build.xml is successfully compiled when executed from JDeveloper
    2.) Both Ant versions are one and the same (Apache Ant 1.7.0)
    3.) Oracle_home points to the SOA installation folder
    4.) Appropriate classpath is set
    I am unable to drill down on this issue further. Is there any small setting (like additional classpaths, oracle_home etc..) that I am missing out here? or is there a jar file that is required by the external Ant builder to execute the <validateTask> and other custom bpel ant tasks?
    Any help would be greatly appreciated.
    Thanks!
    Regards,
    Sathya

    Hi James,
    Let me clear this again. Whenever i try to compile the build.xml of a BPEL process in JDeveloper IDE, I am able to do so without any issues. However, when i try to execute or call the build.xml from a command prompt, I am facing the following error. The "validateTask" ant task is the first task and I dont think that has anything to do with the connection settings as this task will get executed the first in any BPEL process even before <bpelc> (Compilation) or <deployProcess> (deployment) tasks.
    I think I am missing some classpath/libraries/ant settings required for calling the build.xml externally.
    Any help would be greatly appreciated. Thanks!
    Regards,
    Sathya

  • Form Filler Yellow Task Bar Link Does Not Open task or do anything SharePoint 2010 InfoPath 2010

    Form Filler Yellow Task Bar Link Does Not Open task or do anything (SharePoint 2010 InfoPath 2010)
    Using a SPD workflow to run a approval process. This is a non-browser form. User receives task notification, opens form in IP Form Filler and sees yellow task bar notification. User Clicks on open task, nothing happens... OS = XP, On Win7
    = We get a never ending download box, and several logon security windows
    Attempted Fixes
    Clear
    InfoPath Cache
    Workflow History Looks good

    Hi,
    I understand that when you click on Edit this task in the message bar in InfoPath 2010, nothing happens. Does this happen when you open the email which contains the ‘Edit this task’ link?
    If so, you can try to check whether this key is in your regedit. If so, you can delete this key and have a test.:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{00000000-0000-0000-0000-000000000000}
    Back up the regedit keys before making any changes. For more information about backup and restore the regedit, please refer to these sites:
    Fix “Edit this task” In Outlook 2007:
    http://vettekerry.wordpress.com/2008/06/11/edit-this-task-in-outlook-2007-doesnt-work/
    How to back up and restore the registry in Windows XP:
    http://support.microsoft.com/kb/322756?wa=wsignin1.0#method1
    Thanks,
    Entan Ming
    Entan Ming
    TechNet Community Support

  • Notes with tasks appearing twice in mail

    Has anyone experienced a problem with notes in email where you create a note with tasks and find after you restart the computer that the note's contents have altered and/or the note itself duplicated so you now have two versions of the same note?

    This happens to me a lot as well. This hinders my attempt at using Mail 3 for serious GTD. I've also experienced problems where the notes is losing its type. It somehow reverts to X-Uniform-Type-Identifier: com.apple.mail-message instead of X-Uniform-Type-Identifier: com.apple.mail-note.
    Once in that state, all the todo are lost and you have to recreate the note. Very, very bad.
    I'm surprisingly disappointed at the lack of stability of the note feature. Seems rushed to market. Not my typical Apple experience.

  • My iPad Prefs are set for the side switch to Mute; but the speaker does not mute when the switch is moved down.

    My iPad Prefs are set for the side switch to Mute; but the speaker does not mute when the switch is moved down.

    That setting only works for system sounds like push notifications (emails and the like), some game sounds, keyboard clicks and things like that. If you want to mute all sounds you still have to turn the volume all the way down with the volume switch.

  • Q10 sync to MS Outlook 2010 - Notes and Tasks

    Anyone got Notes and Tasks to synch between MS Oultook and the Q10?

    I find it shocking that this "issue" has still not been resolved.  Why do you keep giving people reasons to switch?  Tasks and notes are integral to many people's BB experience...

  • HT1386 What is the procedure to sync Outlook 2011 Contacts, Calendars, Notes, and Tasks to my iPhone4S using OS X Version 10.8.3?

    What is the procedure to sync Outlook 2011 Contacts, Calendars, Notes, and Tasks to my iPhone4S using OS X Version 10.8.3?

    Ideally your iPhone and Outlook would be setup to use an Exchange account

  • What is the procedure to sync Outlook 2011 Contacts, Calendars, Notes, and Tasks to my iPhone4S using OS X Version 10.8.3?

    What is the procedure to sync Outlook 2011 Contacts, Calendars, Notes, and Tasks to my iPhone4S using OS X Version 10.8.3?

    When the phone is connected to the computer in iTunes, go to the Info tab and select Outlook as the source for Contacts and Calendars. Tasks will not sync, but Notes can be selected to sync as well.

  • Con not assign TASK TYPE for Put away during PO receipt

    Good morning everyone!
    I spent a lot of time to setup WMS Task assigment rule with no result.
    My goal is to make Task assigment for inbound tasks. Particulary put away after receipt.
    Expected behavor: after receipt in receiving area system should assign task type. This can be checked via "Warehouse control board" form, "Task type" column.
    Actual (current behavour): task is created and even can be seen via "Warehouse control board" form. But there's no task type. For Task assigment the only rule exists.
    To be sure that it works with other tasks types I've checked on Move order. Works well.
    NEED YOUR ADVISE
    Thanks in advance.
    Eugene.

    This case happened to me too in R12.
    The system did not assign task type after receipt in the receiving area. Moreover, I cannot update status from "Pending" to "Queue" to the user via "Warehouse Control Board" form for these put away tasks. It always show the error message "Cannot update putaway task." after press execute button. So How can I assign these task to specific user?
    Need your advise too,
    Thanks,
    Surachai.

  • IPad 2 Mute button does not mute youTube videos or games

    I noticed iPad mute button does not mute youTube videos or games. When the button is set to mute, videos or games have their own sound so I have to adjust it manually only after I can hear the sound.
    Any suggestions on how to mute all sounds at once?

    Muting is meant to mute the system sounds like the phone ring and text message notification, it won't mute music or video or games. Use the volume control to turn the audio down.

  • Hi i just wanna ask about the volume down button in the ipad 2 ,it was mute the device when hold it at once but before 2days i noticed that the device did not mute when i hold it ,why? and how i fix this by the way it is still volume down

    hi i just wanna ask about the volume down button in the ipad 2 ,it was mute the device when hold it at once but before 2days i noticed that the device did not mute when i hold it ,why? and how i fix this by the way it is still volume down

    Have you tried restarting or rebooting the iPad and then see if the volume control will work again?
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Transferring Notes and Tasks

    Just got my Droid Incredible and used HTC Sync to get my calendar and contacts from my company's Outlook system.  So far, so good.  But what about Outlook notes and tasks?  Is there some way to get these transferred over?
    Thanks
    Dennis

    Yes the best way is to just type outlook into the search bar in the android market. A few I found that work are: gTasks, Astrid, Touchdown, and also companion link. Hope this helps.

  • Q10 sync outlook notes and tasks

    please fix the q10 so it can sync outlook notes and tasks - a very important feature!

    I find it shocking that this "issue" has still not been resolved.  Why do you keep giving people reasons to switch?  Tasks and notes are integral to many people's BB experience...

Maybe you are looking for

  • CK71 suddenly hang when taking a picture using the camera

    Hi team, The customer is using the CK71 with camera option. OS is. 1.61.22.72. Our partner developed the camera application based on Intermec source file according to the IDL(Multimedia Resource Kit). Regarding the source that the partner tested, I a

  • File is not comming to target system

    Hi guru, i did the file to file scenario as per the Srinivas Vanamala blog. /people/srinivas.vanamala2/blog/2007/02/05/step-by-step-guide-xml-file-2-xml-file-scenario-part-i /people/srinivas.vanamala2/blog/2007/02/05/step-by-step-guide-xml-file-2-xml

  • NPE after migration of html from 11.1.1 to 11.1.1.1

    After migrating a working simple html project to the newest version 11.1.1.1 I've got the following error. Does someone know a solution? Thanks Ognian Performing action Run[ from oracle.ide.navigator.ProjectNavigatorWindow ] Performing action Externa

  • 4 Data Mining engineering positions at Yahoo! Inc (Sunnyvale/Burbank, CA)

    There are four positions open in our group at Yahoo, with Data Mining being the key requirement (not necessarily Oracle DM). We are prepared to move very quickly on them - meaning we guarantee that you will be called the next business day after sendi

  • Content administration authorization

    Hi Gurus, Can any body tell how to give only content administration authorization to user i have created one role and i have assigned the work set contentent administration to that role, and given the end user permissions to user and assignd the role