Two problems , you're not passing arguments, which means you're using global variables ... argument passing is what its all about (see Re^4: Query the height of Tk::Text widget with word wrap)

The other thing is, use Thread::Queue, and then you can in one thread do only tk stuff (get data from inqueue, do stuff with it, put data on outqueue) and it the other thread you do the talking with the serial port, however many loops and blockiness and whatever you need ... (see Re: Win32::GUI window freezing, even with threading. (win32-gui-tk-thread-dequeue.pl, Thread::Queue::popnow/push))

This might help :) Re: Win32::GUI window freezing, even with threading. (win32-gui-tk-thread-dequeue.pl, Thread::Queue::popnow/push) + Re^4: Win32::GUI window freezing, even with threading. (Wrong solution), Re: Tk: Creating label in hash, Re: perl Tk thread help, Re: error on file open, Re^4: Query the height of Tk::Text widget with word wrap

Also, food for thought, tk serialport,site:perlmonks.org tk serialport -> Marrying Tk, threads and SerialPort - a COM port monitor, Re: Perl Tk and Threads


In reply to Re: Perl/Tk vs Win32::SerialPort by Anonymous Monk
in thread Perl/Tk vs Win32::SerialPort by Shaoboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.