That was it....my UI thread was updating the TileExtents from another
play and caused the loop to exit.
Done in again by my own doing :)

Problem solved

On Mar 27, 11:37 am, martypantsROK <martyg...@gmail.com> wrote:
> No dice. Tried catching a Throwable both when I start the thread and
> on the inner loop of the work.  Nothing. No Errors.
>
> What kinds of operations might make a thread stop?  The only thing
> that prevents it from iterating all the loops is whether the local
> Boolean 'found' is set and it comes back false when it hasn't
> finished.
>
> I think I must be stepping on some memory somewhere so I'll go down
> that path.
>
> Thanks for the tips, Dianne.
>
> On Mar 27, 11:15 am, Dianne Hackborn <hack...@android.com> wrote:
>
>
>
>
>
>
>
> > Try catching a Throwable to see if an error is happening that you are
> > missing.
>
> > On Tue, Mar 27, 2012 at 1:54 AM, martypantsROK <martyg...@gmail.com> wrote:
> > > I would have thought the same, too - AsyncTask or Thread - there's
> > > something else going.
>
> > > Here's what is called by doInBackground() - it's a loop through
> > > possible moves until the first fit is found.
> > > My Log.d("WTF"...) in the middle simply stops after a couple of
> > > columns.
>
> > >    private Boolean doSearchforSpot(){
> > >        Boolean found = false;
> > >        tileClass tile;
> > >        int tileNum;
> > >        BoardClass spot;
> > >        int rot;
> > >        int maxrot;
> > >        int score = -1;
> > >        int i = 0;
>
> > >        // totally brain-less, brute-force, 1st fit.  Loop through
> > >        // all open spots on the board, and check each tile in each
> > > rotation
> > >        // and return the first time a valid placement and score occurs.
>
> > >        while ((i < deviceHandNumber) && (!found)) {
> > >                tileNum = deviceHand[i];
> > >                tile = tiles.get(tileNum);
> > >                int row = TileExtents[TOP];
> > >                int col = TileExtents[LEFT];
> > >                while ((row <= TileExtents[BOTTOM]) && (!found)) {
> > >                        while ((col <= TileExtents[RIGHT]) && (!found)) {
>
> > >                                spot = board.get(ColRowGrid[col][row]);
> > >                                if (!spot.occupied) {
> > >                                        if (spot.facedown) {
> > >                                                rot = 3;
> > >                                                maxrot = 6;
> > >                                        }
> > >                                        else {
> > >                                                rot = 0;
> > >                                                maxrot = 3;
> > >                                        }
> > >                                        while ((rot < maxrot) && (!found)) 
> > > {
> > >                                                // set the rotation and
> > > check for a score
> > >                                                tile.setRotate(rot);
> > >                                                Log.d("WTF","CRT "+col+"
> > > "+row+" "+rot+"
> > > "+tile.getScore(0)+" "+tile.getScore(1)+" "+tile.getScore(2));
> > >                                                score =
> > > placeTileOnBoard(spot.index, tileNum);
>
> > >                                                if (score >= 0) {
> > >                                                        // hey! we found a
> > > spot. Play it.
> > >                                                        turnScore = score;
> > >                                                        currentTile =
> > > tileNum;
> > >                                                        found = true;
> > >                                                }
> > >                                                rot++;
> > >                                        }
>
> > >                                }
> > >                                col++;
>
> > >                        }
> > >                        row++;
> > >                        col=TileExtents[LEFT];
> > >                }
> > >                i++;
>
> > >        }
> > >        return found;
>
> > >    }
>
> > > On Mar 27, 10:37 am, Dianne Hackborn <hack...@android.com> wrote:
> > > > If your thread is stopping, it is an issue in your implementation of
> > > > doInBackground(), which you haven't shown.  And whatever your problem 
> > > > is,
> > > > you will have it with a Thread as well.  AsyncTask is just doing work
> > > from
> > > > threads, after all.
>
> > > > On Tue, Mar 27, 2012 at 1:18 AM, martypantsROK <martyg...@gmail.com>
> > > wrote:
> > > > > I have an operation that consumes too much time for the UI thread and
> > > > > need to do it in another thread. I created a thread using AsyncTask
> > > > > and the thread loops until it finds and answer. When its done, I use
> > > > > postExecute to deal with the data and update views. The problem is
> > > > > that the thread intermittently stops in the middle of a long loop with
> > > > > no errors. Sometimes it goes through all data looking, sometimes, the
> > > > > thread returns having only looped through a portion.
>
> > > > > I posted a question on Stackoverflow, but the only answer I got was
> > > > > not to use AsyncTask but just use threads without providing any
> > > > > reasoning or details why one is better than another.
>
> > > > > What do folks here think?  Is there something wrong with the way I've
> > > > > implemented my AsyncTask? Or is the stackoverflow poster correct in
> > > > > that I should just blindly use Thread without understanding why this
> > > > > is incorrect, good, bad, ugly or whatever.
>
> > > > > private void playDeviceTile() {
>
> > > > >    if (mDbHelper.isPlayingDevice(game_id)) {
>
> > > > >        // make sure I'm seeing all played tiles
> > > > >        refreshPlayedTiles();
>
> > > > >        final Boolean found;
>
> > > > >        final ProgressDialog dialog = new ProgressDialog(mcontext);
> > > > >        dialog.setMessage("Android is thinking...");
> > > > >        dialog.show();
>
> > > > >            new AsyncTask<Void,Void, Boolean>(){
> > > > >                @Override
> > > > >                protected void onPostExecute(Boolean isFound) {
> > > > >                    if (!isFound) {
>
> > > > >                            passPlay(1);  // never found a tile to
> > > > > play. We have to pass
> > > > >                        }
> > > > >                        else {
> > > > >                           playTile(currentTile,1);
>
> > > > >                       }
> > > > >                    dialog.dismiss();
> > > > >                    postInvalidate();
> > > > >                    invalidate();
> > > > >                }
>
> > > > >                @Override
> > > > >                protected Boolean doInBackground(Void... params) {
> > > > >                    try {
> > > > >                        return doSearchforSpot();
> > > > >                    } catch (Exception e) {
> > > > >                        Log.e("DRAW", "Exception find spot for device
> > > > > tile", e);
> > > > >                    }
> > > > >                    return null;
> > > > >                }
>
> > > > >            }.execute();
>
> > > > >    }
> > > > > }
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to
> > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > hack...@android.com
>
> > > > Note: please don't send private questions to me, as I don't have time to
> > > > provide private support, and so won't reply to such e-mails.  All such
> > > > questions should be posted on public forums, where I and others can see
> > > and
> > > > answer them.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see and
> > answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to