Can a server handle threads?

I have a server that
a) recieves data
b) updates a database
c) sends data to clients
I tried putting the database update into a separate
thread :
Runnable task = new Runnable() {
public void run() {
//i have a print statement here
//which is not reached
//database update in here
so now the server recieves data and sends it to the clients
but it never updates the database.
Are there any issues that you are aware of with starting threads on
a server?
thanks,
zeke

Thanks for responding.
Here is some more detail...
static class TaskRunner {
                private final static int TIME_TO_WAIT = 60000;    
                private Queue q = new Queue();
                class MonitorThread extends Thread {
                        private Thread t;
                        private boolean go;
                        private boolean timeout;
                        MonitorThread(String name, Thread t) {
                                super(name + " monitor");
                                this.t = t;
                                this.start();
                        public void run() {
                                while (true) {
                                   // wait for tick off
                                   synchronized(this) {
                                        go = false;
                                        while (go == false) {
                                                try {
                                                        wait();
                                                catch (InterruptedException ex)
                                                        //ignore
                                        // get out of this wait either in timeou
t or reset
                                        try {
                                                wait(TIME_TO_WAIT);
                                        catch (InterruptedException ex) {}
                                        if (timeout == true) {
                                                CoreUtil.beep();
                                                printDebugMessage("***** " + t.g
etName() + " timeout " + TIME_TO_WAIT + "ms !!!!!!!!");
                        synchronized void begin() {
                                go = true;
                                notify();
                class TaskRunnerThread extends Thread {
                        private MonitorThread monitor;
                        TaskRunnerThread(String name, boolean monitorOn) {
                                super(name);
                                if (monitorOn) {
                                        this.monitor = new MonitorThread(name, t
his);
                                        yield();
                                CoreUtil.setPriority(this, Thread.MIN_PRIORITY +
2);
                                CoreUtil.setDaemon(this, true);
                                this.start();
                        * Get a message from the queue, block if there is no mes
sage.
                        * @return the message.
                        public void run() {
                                while (true) {
                                        if (monitor != null) {
                                                monitor.reset();
                                        Runnable task;
                                        synchronized(TaskRunner.this) {
                                                while (q.isEmpty()) {
                                                        try {
                                                                TaskRunner.this.
wait();
                                                        catch (InterruptedExcept
ion e) { }
                                                task = (Runnable) q.pop();
                                        // a null task signal for exit
                                        if (task == null) {
                                                return;
                                        if (monitor != null) {
                                                monitor.begin();
                                        try {
                                                task.run();
                                        catch (Exception ex) {
                                                printDebugMessage("Exception in
runnerTask: " + ex);
                                                ex.printStackTrace();
                                        task = null;       // null out so we don
't hold reference here
                // create a TaskRunner object with the specified number of work
threads
                TaskRunner(String name, int n) {
                        this(name, n, false);
                // create a TaskRunner object with the specified number of work
threads
                TaskRunner(String name, int n, boolean monitorOn) {
                        // create a pool of RunnerThread so in case one is block
ed
                        // we are not block totally.  It's a very bad sign if an
y
                        // of these thread a block for a long time
                        for (int i = 0 ; i < n ; i++) {
                                new TaskRunnerThread(name + " " + i, monitorOn);
                * Execute the subribe command
                * @param m the messsage
                synchronized void execute(Runnable task) {
                        q.push(task);
                         notify();
        public static void runTask(Runnable task) {
                printDebugMessage("in runTask "+task);
                if(taskRunner == null)
          taskRunner = new                                   TaskRunner("CoreUtil.TaskRunner Thread", 3);
                taskRunner.execute(task);
        public static void close(){
                taskRunner = null;
//then i call this
runTask(new Runnable() {
     public void run() {
          //update database
});do you see any reason why the thread wouldn't start?

Similar Messages

  • How much volume can this server handle?

    Post Author: mronquillo
    CA Forum: General Feedback
    I'm not really sure where to post this. If I posted in the wrong section, please forgive me.I am running Business Objects Enterprise XI R2 on a rack-mounted server with the following specs:Quad Core Intel Xeon processor 2.0 GHz4 hard drive 73 GB each Raid 54 GB RAMWindows 2000 ServerRight now, my user base numbers around 20 or so users. My company is thinking of using the server as a reporting solution for a larger business unit, expanding the user base to around 100+ users. How much volume do you think my server can handle? Would it be enough to handle this amount of users? Or is more processing power/scaling needed?

    Get your hands on the ever-useful app, Mactracker. It lists all the specs for one's Mac including the latest capacity for RAM.
    You can get it here or at the Mac App store (and iOS store)
    http://www.mactracker.ca/index.html
    For your model;

  • How many concurrent streams can my server handle?

    I am trying to serve streaming video over a 10 mb network and using Adobe® Flash® Media Streaming Server 3.5.  Here are the specs on the video.
    Video:
    Codec: On2 VP6
    320x240px
    frame rate: 30fps
    400 kbps (VBR)
    keyframe distance: 15
    Audio:
    Mono channel
    96 kbps
     Does anyone know how many of these I could serve up concurrently?  Or is there a spec somewhere?

    It might be that straightforward question to answer because your network might support "x" mbps but your server configuration including CPU,Memory,Network card you have.
    If you need to do simple calculation (considering you have calculated your bandwidth for video and audio individually) it would like one client would take around 496kbps. Now that means roughly 2 clients will take 1 Mbps so 20 clients will eat up 10Mbps - so at given point of time only roughly 20 clients would be able to play stream without much of rebuffering issue.
    Any number of clients would be able to connect and play but more the clients quality of service for each client might start degrading , they might start getting insufficient bandwidth messages.

  • Can OSX Server, et al, handle this website's load?

    I looked through this forum and the one on Xserve and couldn't find a topic like this.
    The site is being converted from an obscure programming language to PHP/MySQL. In functionality, it will resemble a Craig's List for college students. Lots of database interaction. Very few graphics except for multiple small banner ad deliveries on each page. Lots of email interaction generated by a form at the site.
    We're planning on picking up a new Xserve, dropping a couple of those 15k rpm drives the Apple Store sells into it, and boosting the RAM to 4gb (?).
    What I'd like to know is the following:
    1. Can someone give any real world numbers on the performance of OSX/Apache 2.2/MySQL and said hardware? Can the database handle 100k, 500k, 1M records? Are there general rules for how many page views per day that can be served? (Bandwidth should not be an issue...I believe we are allocated 1TB per month, and as I indicated, graphic content is low.)
    2. If the server and software can handle X, would is the next logical step beyond X? I realize that this may never happen, but I do need to ask the question for my own peace of mind. In other words, how does one expand beyond the fastest hardware and what I perceive to be as the best software solution?
    Right now the site is at zero, and everyone dreams of building the next MySpace or YouTube. If it flops or just never generates tons of traffic, I can figure out how to handle that. My concern is if it does go in the other direction, so, any tips/suggestions would certainly be welcomed. Thank you in advance.
    Rob

    > Can someone give any real world numbers on the performance of OSX/Apache 2.2/MySQL and said hardware
    In most cases bandwidth will be your limiting factor more than CPU resource.
    1TB might sound like a lot - and it is if you're doing mostly text-based content - but on a typical traffic sine-curve it equates to about 300kbps. Your server is more than capable of handling that without breaking a sweat (database schema notwithstanding).
    All my servers are running multi-megabits per second and I still have room to grow.
    1 million rows in a MySQL database is not large. I have MySQL databases using hundreds of millions of rows. Beware of your database schema (query optimization and indexes will make a BIG difference to performance).
    The next logical step as far as scaling would be multiple front-end web servers talking to the database server. There are numerous solutions for load balancing traffic across multiple servers, depending on $$s and flexibility needs.
    The biggest factor is going to be in choosing the language to write the site in. PHP isn't necessarily the best choice. You need to be very careful (and not an 'average' PHP programmer) to be able to eke the best performance out of a busy site (esp. when it comes to database interactions - you need to cache the data in the app rather than hitting the database for every single page hit).
    There's nothing wrong with PHP - just be aware of its limitations and be prepared to deal with it (whether through code optimization or another language switch).

  • Exception in handler thread. in BI Presentation Services

    Hi
    We are revicing following error in OBIEE 11g presentation services
    Dose anyone know the reason?
    +Exception in handler thread. An error occurred during execution of "send". Broken pipe [Socket:82]^M+
    Error Codes: ETI2U8FA^M
    Location: saw.rpc.variablemos.finalize, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool, saw.threadpool, saw.threads^M
    +[[+
    File:socketrpcserver.cpp
    Line:565
    Location:
    saw.rpc.server.handleConnection
    saw.rpc.server.dispatch
    saw.threadpool

    Hi ,
    By any chance have you changed anything in socketrpcserver.cpp ??
    looks like the file has changed or not copied propelry.
    Open the socketrpcserver.cpp in vi editor and check if it contains any control M charatcers (^M).
    Or
    It can be because of the JavaHost process not running. Check instanceconfig.xml (check the port number)
    If you have changed the JavaHost Port Number (default is 9810), you need to update it in instanceconfig.xml.
    <JavaHostProxy>
    <Hosts><Host address="myhost.domain.com" port="newport>" /></Hosts>
    </JavaHostProxy>

  • HANDLER THREAD PROBLEM?

    I'm trying to use the method Response.sendRedirect to forward users to another website. The actual case is irrelevant so I've extracted the important part into a simple servlet example:
    import javax.servlet.http.*;
    import java.io.*;
    public class ReDirect extends HttpServlet
       public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
          if(req.getQueryString()!=null)
             res.setContentType("text/html");
             res.getWriter().println("Your querystring: <b>"+req.getQueryString());
          else
             res.sendRedirect("http://java.sun.com");
    }The funny thing is that the servlet works FINE, but that darn thing is generating an IOException (showing in the DOS prompt of the webserver) everytime the sendRedirect method is called! Why?
    ReDirect: init
    HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
    java.io.IOException: Socket Closed
         at java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:432)
         at java.net.Socket$1.run(Socket.java:335)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.Socket.getInputStream(Socket.java:332)
         at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)I have tried everything... I've also searched the forum for similar problems, but it seems that noone have a logic explanation for this. Is this a bug in the servlet engine or is it something I'm doing wrong or have forgotten?
    I'm using jswdk 1.0.1 and jdk1.3.1 on windows 2000, running the webserver that comes with jswdk.
    Please, someone, explain this to me! This problem is torturing me day and night!!
    /Stefan Westling

    Go get tomcat ...I used to get this error lot's when I used the jswdk. There are just some things it doesn't like ...yet when structured in certain way's ...it would work. I never did track down any consistent explanation. I just moved on to tomcat. The jswdk is really cheesy ...it can't do post ...or sessions ...or any 2.0 functionality ... or ... or ... Go get tomcat.

  • How can I close core thread in ThreadPoolExecutor?

    If I use unbounded LinkedBlockingQueue in ThreadPoolExecutor and set the core pool size to 5. When more than 5 tasks are submitted, there will be 5 threads created to handle the request. After finish, these threads will not be closed. How can I make the threads in core pool be closed when finishing their job? I couldn't use maximum pool for that I do need an unbounded queue.

    If you really want that functionality, set the core pool size to 0, the maximum pool size to 5 or greater, and the keepAliveTime to 0L. This will remove excess threads as soon as their tasks have completed.
    It's very wasteful though if you plan on executing the tasks repeatedly to create new threads everytime you submit a task. One of the benefits of using a thread executor is not having to construct and start a Thread object everytime you run a task.
    Brushfire,

  • Urgent!!!!!!!HANDLER THREAD PROBLEM

    file name GetName.html
    <html>
    <body>
    <FORM METHOD = POST ACTION = "SaveName.jsp">
    what is your name?
    <INPUT TYPE = TEXT NAME=username SIZE= 20>
    <p><INPUT TYPE= SUBMIT>
    </FORM>
    </BODY>
    </HTML>
    file name SaveName.jsp
    <%
    String name = request.getParameter( "username" );
    session.setAttribute( "theName", name );
    %>
    <HTML>
    <BODY>
    Continue
    </BODY>
    </HTML>
    file name NextPage.jsp
    <html>
    <body>
    Hello, <%=session.getAttribute("theName") %>
    </body>
    </html>
    when I try to execute , SaveName.jsp is generating the following error message. what is the problem? I am using jswdk. please help. I have included tools.jar in classpath. what could be the problem?
    Unhandled error! You might want to consider having an error page to report such
    errors more gracefully
    com.sun.jsp.JspException: Compilation failed:Note: sun.tools.javac.Main has been
    deprecated.
    work\%3A8080%2Fexamples\SaveName_jsp_1.java:71: Method setAttribute(java.lang.St
    ring, java.lang.String) not found in interface javax.servlet.http.HttpSession.
    session.setAttribute( "theName", name );
    ^
    1 error, 1 warning
    at com.sun.jsp.compiler.Main.compile(Main.java:347)
    at com.sun.jsp.runtime.JspLoader.loadJSP(JspLoader.java:135)
    at com.sun.jsp.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspS
    ervlet.java:77)
    at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
    ava:87)
    at com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:218)
    at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:294)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155
    at com.sun.web.core.Context.handleRequest(Context.java:414)
    at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
    HANDLER THREAD PROBLEM: java.net.SocketException: Socket is closed
    java.net.SocketException: Socket is closed
    at java.net.Socket.getInputStream(Socket.java:643)
    at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)

    Are you using JSWDK 1.0.1? If you are, then the implementation uses the Servlet Spec. 2.1. The set/getAttribute methods were added in 2.2.
    Try using the now-deprecated method putValue like this in SaveName.jsp.
    <%
    String name = request.getParameter( "username" );
    session.putValue( "theName", name );
    %>

  • Can VI server automatically close access for clients' VIs, if one of clients is already connected?

    Can VI server automatically close access for clients' VIs, if one of clients is already connected? and when first client closed reference, open access for other clients' VIs? I mean like when you use web publishing tools. If one user already uses front panel.. other just can wait until first one will finish.

    Please stick to one thread.  Here is the original.

  • Is there anyway we can remove a perticular thread from a threadgroup?

    Is there anyway we can remove a perticular thread from a threadgroup?
    The context is like this :
    I am creating a thread to monitor a server, that monitors it after perticular timeperiods.
    while creating it i register this thread into a thread group too.
    So when i want to stop this thread ,i also want to remove this from a threadgroup also.
    Is there anyway we can do it ?

    dear davidholmes :
    I've checked it , if i interrupt a thread ,it will be
    removed from the thread group.The interrupt is just a means for you to tell the thread you'd like it to terminate. It is termination that removes the thread from its group.
    But wht about the thread object in memory(i.e. in
    running environment)
    will it also be eligible for garbage collection ?A thread that isAlive can't be GC'ed, after that ... you already have the answer.

  • I'm using iTunes 10.6.1 on an iMac 2,66 Ghz intel core Duo with8GB DDR3 and Lion 10.7.3 I hav 260000 mp3 stored on A My Book 3 TB external Fire wire 800 Drive - when I play songs I get short interuptions every 20 to 30 seconds. Can't iTunes handle that?

    I'm using iTunes 10.6.1 on an iMac 2,66 Ghz intel core Duo with8GB DDR3 and Lion 10.7.3 I have 260000 mp3 stored on a My Book 3 TB external fire wire 800 Drive - when I play songs I get short interruptions every 20 to 30 seconds. Can't iTunes handle that number of songs?

    I'm using iTunes 10.6.1 on an iMac 2,66 Ghz intel core Duo with8GB DDR3 and Lion 10.7.3 I have 260000 mp3 stored on a My Book 3 TB external fire wire 800 Drive - when I play songs I get short interruptions every 20 to 30 seconds. Can't iTunes handle that number of songs?

  • Can Windows Server Backup spread a single backup job across multiple disks if they are not set up as a virtual disk?

    This may be a dumb question, but I can't seem to find any definitive information after having done many, many searches.  Short question is - can Windows Server Backup spread a single backup job across multiple disks if they are not in a storage
    pool or some other RAID/JBOD structure?
    Background:
    I'm running Server 2012 Essentials with all Windows Updates installed.  I have been backing up approx 2.8TB of data (Bare Metal Recovery, C:, S: (shared folders), and system reserved) for the past year+ onto a storage pool made up of two-2TB external
    USB drives.  Backup is slow (takes approx 1.5 days to complete), but generally works.  Not surprisingly I was constantly getting capacity low messages so I decided to increase my backup storage pool by adding a 3TB drive and another spare 750GB drive
    for a total of 7.75TB.  Instead of having four separate external USB enclosures, I bot a 4-bay enclosure - Startech.com model #S3540BU33E to simplify this (or so I thought!).
    The first problem I had was adding the two new drives to the existing storage pool. I think that is because the Startech uses a JMicron USB controller that reports identical uniqueid's for all drives so only one shows up in the GUI interface for creating storage
    pools. After doing research on this, I set up a new storage pool and virtual disk using all four drives via Powershell and thought I was good. However, when the backup ran, it failed after filling the first drive, saying there was no remaining capacity. In
    reality there were three remaining empty drives and there storage pool reported almost 5TB of avail capacity. I assumed this was due to the identical uniqueid issue so I decided to try a different tactic.
    Instead of using a storage pool that combines all four disks into one virtual disk, I just added each of them to Windows Server Backup as individual drives thinking it would manage them collectively. I.e., when a drive filled up during a particular backup,
    it would just start using the next drive and so on. Apparently this was a foolish assumption because the backup failed again as soon as the first disk filled up.
    So now I don't know if this is still an issue with the identical uniqueid's or if Server Backup actually can't spread a single backup across multiple individual drives that aren't in a pool or other virtual disk implementation. Hence, my original question.
    My guess is that it does *not* spread them across individual disks, but I just wanted to get confirmation.
    Thanks

    Mandy,
    Thank you for following up on my question.
    Unfortunately the article you referenced doesn't address what I am trying to accomplish.
    The article focuses on saving the same backup job to multiple disks and rotating the disks between on and offsite for enhanced protection.  However, it still requires that an individual backup job fits on a single disk.
    What I am trying to determine is if a single backup job can span across more than one physical disk (during the backup process) without those physical disks being in some type of virtual disk implementation (e.g., storage pool, RAID, etc.).
    Thanks,
    Gerry

  • Jdeveloper threads?? how can I start a thread?

    Does anyone know how I can automatically set a thread in motion once I call a file in the project? I basically want a background process to run constantly while my app runs.
    Any thoughts??

    Try this:
    http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html
    http://developer.java.sun.com/developer/Books/threads/chap9.pdf
    Linda
    null

  • Can I get handle to Database Row before an entity is deleted

    Hi,
    We are using stored procedure to list, insert , update and delete entity objects.To use the stored procedure I override the default queries generated by Toplink and make use of the stored procedure query.The issue here is that my Stored Procedure requires more arguments (like name of the user doing the insert) than there are fields in the entity.I need to provide these argument values to the call.For this I do something like
    session.getDescriptor(MyClass.class).getEventManager().addListener(new DescriptorEventAdapter(){
         public void aboutToInsert(DescriptorEvent evt) {
         evt.getRow().put("USER",evt.getSession().getProperty("username"));
    I set the username in the unitOfWork out of which I can grab the value in the eventHandler and put it inside the row just before insert.I do the same for modify too.But I dont see a similar methods for "delete".Do we have a aboutToDelete() method where I can get a handle to the row.The preDelete() does not provide a handle to the row.How can I insert additional arg values to the delete query?
    Thanks,
    Harini

    Hello Harini,
    Wow, you are correct there is no aboutToDelete, I guess manipulating the row before deletetion is not that common for our TopLink clients as this is the first request I have heard for it. I will add this request to our enhancement database. You might want to follow it up with support if it is a priority for you.
    As a workaround you could use the preDelete event to change the stored procedure call with the user name argument (i.e. build the procedure call dynamically in preDelete and set it into the query. The query will have been cloned at this point so there should be no concurrency issues. Make sure when doing this that you do not set the deleteQuery in the descriptor query manager as this will override the original query if set.
    Example:
    descriptor.getEventManager().addListener(new DescriptorEventAdapter() {
    public void preDelete(DescriptorEvent event) {
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("Delete_proc");
    call.addNamedArgument("P_ID", "ID");
    call.addNamedArgumentValue("USER", "scott");
    call.addNamedArgumentValue("TIME", new java.util.Date());
    event.getQuery().setCall(call);
    });

  • Can use the same thread safe variable in the different processes?

    Hello,
    Can  use the same thread safe variable in the different processes?  my application has a log file used to record some event, the log file will be accessed by the different process, is there any synchronous method to access the log file with CVI ?
    David

    Limiting concurrent access to shared resources can be better obtained by using locks: once created, the lock can be get by one requester at a time by calling CmtGetLock, the other being blocked in the same call until the lock is free. If you do not want to lock a process you can use CmtTryToGtLock instead.
    Don't forget to discard locks when you have finished using them or at program end.
    Alternatively you can PostDeferredCall a unique function (executed in the main thread) to write the log passing the apprpriate data to it.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

Maybe you are looking for

  • How to read a text file from other machine???

    I have a text file located in local machine. I use th e code below to retrieve data from that particular text file. String realPath     = (String)getServletContext().getRealPath(""); BufferedReader holsFile = new BufferedReader(new FileReader(realPat

  • How to activate an InfoObject in background in target system

    Hello, after I made changes to an characteristic InfoObject in development system I have activated it in background, this has run the background job  IOBJ_ACTIVATE. When I transported the IO change and activation into the test system, the IO has been

  • Graphics bug making software unusable. "Ghosting" effect whenever scrolling through piano roll or tracks window

    As stated in the title, a bug has started plaguing my copy of Logic Express 9 ever since I updated to Yosemite. Whenever I scroll back and forth through the tracks window or the piano roll, this sort of ghosting effect appears and makes manipulating

  • Media Skin issue

    Help... I managed to figure out how to create a nice media skin with no thanks to the incomplete and confusing instructions on the Apple Quicktime tutorial, but with many thanks to kkirkster's website and a few others. I am, however having an issue w

  • Click on link--Display or Download?

    When a user clicks on a file item link in a folder the object is opened and displayed in their browser. I have been told that there is a standard functionality that allows the user to choose if they want want an item saved or opened and displayed whe