How to lock a function while it is in processing?

i am using threads to write my game server side. anyone have any idea on how to lock a function while it is in process? then it wl continue after a process. appreciate very much

   public void run() {
        try {
            char charBuffer[] = new char[1];
            // --- while we have an incoming stream
            while(in.read(charBuffer,0,1) != -1) {
                // --- create a string buffer to hold the incoming stream
                StringBuffer stringBuffer = new StringBuffer(8192);
                // --- while the stream hasn't ended
                while(charBuffer[0] != '\0') {
                    // --- add the character to our buffer
                    stringBuffer.append(charBuffer[0]);
                    in.read(charBuffer, 0 ,1);
                if(stringBuffer.toString().equals("IP")){
                    getMachineId(this.getIP());
                   } else{
                    // --- analysis the XML
                    parseReceivedXML(stringBuffer.toString());
        } catch(IOException ioe) {
            server.writeActivity("Client IP: " + ip + " caused a read error "
                    + ioe + " : " + ioe.getMessage() + "and has been disconnected.");
        } finally {
            killClient();
    }above is my run() code. i want to lock the function parseReceivedXML() and release it to the waiting thread after a thread finish process. i want the threads queue up to run in this function. please help

Similar Messages

  • How to use SQL() function while writing scripts in BODS 4.0

    How to use SQL() function while writing scripts in BODS 4.0

    Hello,
    I think you want to post your question to the [Data Integration and Data Quality Management|Data Services and Data Quality; forum. This forum is for other BusinessObjects SDK development questions.
    Sincerely,
    Dan Kelleher

  • How to lock my computer while playing a video?

    I am setting up my MacBook up to loop a video to leave playing at a booth for a convention, and was wondering if I play a video if there was a way to lock the computer up so no one can quit the video or surf the web or anything like that?
    Thanks for any help.

    Search these forums for kiosk mode and then google for kiosk mode site:apple.com

  • How to restrict  sensitive fields while WF in Approval process?

    Hi Gurus,
    we have a requirement where few fileds should be restricted while WF is in approval prcess and an error msg should display to them that Wf is in process and you cannot change the values.so please help me out on this.

    Hi,
    you could fiddle around with lock mechanisms.
    But ottherwise you would have to do some additional programming at the transaction side.
    If there is a badi, use fm  SAP_WAPI_WORKITEMS_TO_OBJECT to retrieve the workitem for that workflow.
    Kind regards, Rob Dielemans

  • How to run a function

    Hi,
    can anyone tell me how to run this functions while generating reports for labels.
    please i need some guidance.
    create or replace function get_label_nextval(p_label varchar2) return integer
    is
    l_last_num integer;
    cursor c_label is
    select last_num from label_id where label = upper(trim(p_label)) for update wait 10;
    pragma autonomous_transaction;
    begin
    open c_label;
    fetch c_label into l_last_num;
    if l_last_num is not null then
    l_last_num := l_last_num + 1;
    update label_id set last_num = l_last_num where current of c_label;
    commit;
    end if;
    close c_label;
    return l_last_num;
    end;
    Thanks and Regards

    ORA-06519: active autonomous transaction detected and rolled back
    Cause: Before returning from an autonomous PL/SQL block, all autonomous transactions started within the block must be completed (either committed or rolled back). If not, the active autonomous transaction is implicitly rolled back and this error is raised.
    Action: Ensure that before returning from an autonomous PL/SQL block, any active autonomous transactions are explicitly committed or rolled back.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10880/e4100.htm#sthref2110
    I think your COMMIT should be moved outside your IF.
    Commit just before your RETURN, after your CLOSE CURSOR statement.
    Edited by: hoek on Jan 4, 2010 1:28 PM typo

  • HT4085 how to lock the tauch screen with some password or dots like android to prevent misuse. And also screen lock to prevent interruption while watching movie reading books etc.

    how to lock the tauch screen with some password or dots like android to prevent misuse. And also screen lock to prevent interruption while watching movie reading books etc.

    You can set a passcode to be requied to unlock the iPad via Settings > General > Passcode Lock. In terms of locking the actual screen whilst using an app, then that isn't currently possible, but with iOS 6 in the Autumn there will be a new 'accessibility' feature (from here) which will allow you :
    ... to limit an iOS device to one app by disabling the Home button, as well as restrict touch input on certain areas of the screen

  • The find box (previous and next) has just stopped functioning while I was reviewing a pdf file. How can I resurrect it?

    The find box (previous and next) has just stopped functioning while I was reviewing a pdf file. How can I resurrect it?

    [discussion moved to Creating, Editing & Exporting PDFs forum]

  • I cannot determine how to utilize the voice function while in the fitness workout area. On rare occasions it works with a voice summary of my workout and a new summary screen. would appreciate help

    I cannot determine how to utilize the voice function while in the fitness mode. On one or two occassions it worked but I do not know how it was activated. It gives a voice summary and new summary screen for the workout.

    Hi shiva
    Thanks for your help,
    Can you check this coding and revert me back ASAP Please.
    REPORT BDS_GOS_CONNECTION.
    DATA : logical_system LIKE BAPIBDS01-log_system.
           CLASSNAME LIKE BAPIBDS01-CLASSNAME
           OBJKEY LIKE SWOTOBJID-objkey.
    PARAMETERS: pa_lo_sys BAPIBDS01-log_system,
                pa_class like BPIBDS01-CLASSNAME,
                pa_objkey like swotobjidobjkey.
    AT SELECTION-SCREEN.
    CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
             EXPORTING
                  bor_id             = bor_id
             IMPORTING
                  logical_sytem      = pa_lo_sys.
                  classname          = pa_class.
                  objkey            = pa_objkey.
             EXCEPTIONS
                  no_objects_found     = 1
                  internal_error       = 2
                  internal_gos_error   = 3.
       IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       ENDIF.
    clear v_attno1.
    i_object1-typeid = 'BUS2012'.
    i_object1-catid  = 'BO'.
    i_object1-instid = i_yItem-docno.
    call method cl_gos_attachment_query=>count_for_object
       exporting
        is_object = i_object1
        ip_arl    = space
       receiving
        rt_stat   = i_stat1.
    read table i_stat1 into wa_stat1 index 1.
    if sy-subrc eq c_0.
        move wa_stat1-counter to v_attno1.
    endif.             
    CALL METHOD cl_gos_attachment_query=>count_for_object
    EXPORTING
    is_object = object
    ip_arl =    space
    RECEIVING
    rt_stat = lt_stat.
    READ TABLE lt_stat INDEX 1 into ls_stat.
    count = ls_stat-counter.
    *The object has to be a concatenation of your document, like this:
    CONCATENATE object-instid tab-gjahr INTO object-instid.
    ELSE.
    CONCATENATE tab-bukrs tab-belnr tab-gjahr INTO
    object-instid.
    ENDIF.

  • How to lock in a book or song while it's playing to avoid bumping the touchscreen

    I have a new iPod Nano and can't figure out how to lock in a song or book while it's playing to avoid having the touch screen bumped and disrupting it.

    Why not just press the sleep/wake button?
    B-rock

  • HT4528 how do i stop my iphone 4 from doing random commands while talking on calls via the touch screen? Can i lock the screen while talking?

    how do i stop my iphone 4 from doing random commands while talking on calls via the touch screen? Can i lock the screen while talking?

    The iPhone has a proximity sensor located on the top of the phone near the earphone speaker that is supposed to automatically turn off the screen when it is close to your face while on a call, to prevent that very thing from happening.  If your phone isn't doing that, try cleaning your screen.  Also, if you put a screen protector on your phone made for a different model it may lack the cut-out that is supposed to keep it from blocking the sensor.  Try removing your screen protector to see if that helps.  If it does, get another screen protector.

  • How can you execute a function while the mouse is over a button.

    I've got a movieclip I want to move across the screen on the x axis to the left or right depending on which button the user hovers their mouse over.
    I thought I could do this with the following:
    right_btn.addEventListener(MouseEvent.MOUSE_OVER, moveRight);
    left_btn.addEventListener(MouseEvent.MOUSE_OVER, moveLeft);
    function moveRight(e.MouseEvent):void
         sampleMovieclip_mc.x += 1;
    function moveLeft(e.MouseEvent):void
         sampleMovieclip_mc.x -= 1;
    But I find that it only moves it 1 pixel when the mouse first goes over the button and not continiously as it stays over it.  I tried using Event.ENTER_FRAME to call the moveRight and moveLeft functions, but it just keeps going and I'm not sure how to kill the function once they move the mouse off of the button.
    Any help would be greatly appreciated.
    Thanks.

    use removeEventListener() method. Here is one of the ways to deal with it:
    // move direction
    var xd:int = 1;
    // speed along x
    var xs:Number = 1;
    right_btn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    right_btn.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
    left_btn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    left_btn.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
    function onMouseOver(e:MouseEvent):void {
         xd = e.curretnTarget == right_btn ? 1 : -1;
         addEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onMouseOut(e:MouseEvent):void {
         removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onEnterFrame(e:Event):void
         sampleMovieclip_mc.x += xd * xs;

  • How does the Delta functionality works while updating Infocube from PA

    Hi Gurus
    How does the Delta functionality works when you send forecast to the Info cube from the Planning Area.
    As I have weekly based planning, every week we have to update the forecast into the Cube. If I update  every week into the Cube , then the values are going to append  in the Info cube.
    Shall I create ODS in between the Planning area  and the Info cube .
    (or)
    Any other method ?
    Please Suggest.

    Hi Preetham,
    Data Extraction from planning area to infocube usually its supports for full update only, when u r going to load the data from planning area to cube ,it deletes the previous data and u vil get the fresh data, this is the best method performance wise,
    if u want to use the delta functionality u can go for planning area to Dso, Dso to cube, it vil supports the delta functionality, but it vil degrades the system performance,
    regards
    ravi

  • How to lock phone while talking - Droid 4

    I used to be able to lock the phone while I was talking so my face wouldn't hang up on people but now I can't find that option and I am constantly disconnecting calls I am on.

        Nicolai lets put an end to those accidental hang ups! Fill us in on the details, when was the last time you were able to the lock the phone? What software are you on? http://vz.to/1eUn1PS . Do you have a phone lock set up? http://vz.to/QoMghR
    AshleyS_VZW
    Follow us on Twitter @VZWSupport

  • How can I disable wifi while playing music with locked ipod touch?

    When I play music and lock the iPod touch, the wifi stays on which drains more battery than is needed. I don't want to turn off wifi in Settings since I like the flexibility to unlock the iPod and quickly check email, browse the web while listing to music (without going into settings, turn it on, browse, go back to settings and turn it off). Once I lock the iPod while playing music, I'd like the wifi to turn off. I know it will stay on while streaming that is expected, but why is the wifi staying on when playing music of the iPod?? Is there a way to do what I am asking? I don't recall having this issue with OS 1.x or 2.x. Also I have seen some posts asking for the opposite (leave the wifi on when not playing music and iPod is locked). These posts acknowledge that wifi stays on while playing music, so it seems to be 'feature' or bug in the OS.

    henry is correct. you can't do that.
    however, for what it's worth, i have found that wifi connection is similar to mobile phone network connection. i.e. if a phone is searching for a network, it takes up huge amounts of battery, but if it is constantly connected, it doesn't. so it is the 'search' procedure which drains the battery. similarly with my iPod touch. if it is connected to my home wifi network, but i am not using the wifi connection, the battery will not drain significantly. it's when i'm away from home and forget to switch it off that the battery drains. or when i am using it constantly (like listening to a 3.5 hr radio show using safari)

  • How to lock a record in a database using java

    hi,
    i want to lock a record in a database. how could it be done.
    if any body has idea pls share with me

    Ok, then you can create a simple lock:
    The idea is same, but this allow you to lock multiple id at the same time:
    static Object LOCK_FLAG = new Object();
    static Object[] locker = new Object[1000]; // assuming you have id 0-999 to lock
        this function will wait until current thread succesfully
        locks all the ids to lock.
    public void lock( int[] idsToLock) {
       while (true) {
           synchronized(locker) {
              boolean success = true;
              for(int i=0; i<idsToLock.length; i++) {
                  if (locker[ idsToLock[ i ] ] != null )
                     success=false;
                  if (!success) break;
              if (success) {
                  for(int i=0; i<idsToLock.length; i++)
                     locker[ idsToLock[ i ] ] = LOCK_FLAG;
                  locker.notify();
                  return;
              locker.notify();
           try {  Thread.sleep(100); } catch (Exception ex) { }
        this function will wait until all locks are released
    public void releaseLock( int[] idsToLock) {
       synchronized(locker) {
           for(int i=0; i<idsToLock.length; i++)
                 locker[ idsToLock[ i ] ] = null;
           locker.notify();
    }How to use:
    int[] recordToLock = new int[] { 1, 100, 55, 32, 25 };
    lock(recordToLock); // lock before modify ..
    try {
       // do anything with your records ...
    } catch (Throwable t) {
       // if any exception ...
    } finally {
       releaseLock(recordToLock);  // make sure this will always be executed
    }rgds,
    Alex

Maybe you are looking for