문제

Is there any idea (library or methodology) to create multithreaded apps in JavaScript?

올바른 솔루션이 없습니다

다른 팁

The closest you're gonna get is web workers (only in FF 3.5 / HTML5). Check it out - http://www.whatwg.org/specs/web-workers/current-work/

SharePoint 2010과 거의 동일합니다. 이들은 당신을 도울 수있는 단계입니다.

  • 사용자 정의 CSS (Custom-RTE.CSS) 파일을 만들고 사이트 모음의 스타일 라이브러리에 게시하십시오.
  • 접두사 스타일 시트 :

  • CSSREGiSTRATION을 사용하여 페이지 레이아웃 / 마스터 페이지의 PlaceholderAdditionalPageHead 내부에 CSS를 추가합니다.

  • 샘플 CSS 코드 :

    /* Custom RTE */
    H1.custom-rteElement-H1
    {
        -ms-name:"My Custom Heading";
        font-family: Arial, sans-serif;
        color: red;
        font-size: 18px;
        font-weight: normal;
    }
    H1.custom-rteElement-H1B
    {
        -ms-name:"My Custom Heading H1B";
        font-family: Arial, sans-serif;
    }
    .custom-rteStyle-Normal {
        background-color: rgba(0, 0, 0, 0);
        color: inherit;
        font-family: inherit;
        font-size: 12px;
        font-weight: normal;
    }
    .custom-rteElement-H1, .ms-rtestate-field H1.custom-rteElement-H1, .custom-rteElement-H1B, .ms-rtestate-field H1.custom-rteElement-H1B
    {
        font-family: Arial, sans-serif;
        color: red;
        font-size: 18px;
        font-weight: normal;
    }
    /* @end */
    

    여기에 이미지 설명을 입력하십시오

Another simulation of threads I found quite stable is to use an image. Which seems to be loaded in another thread in the browser(?). However your callback javascript will run always sequentially.

Here below it loads 500 of them.

<html>
<head>
   <title>so</title>
    <style></style>
</head>
<script>
    function callBack(img){
        var i = 0, img, res = document.getElementById('res'),
            fn = function(cnt){
                var img = document.createElement('img');
                img.onerror = function(ev){
                    res.innerHTML += cnt + ', ';
                    document.body.removeChild(img);
                };
                img.src = 'javascript:void(0)';
                document.body.appendChild(img);
            };
        do{
            fn(i++);
        }while(i<500);
    }
</script>
<body onload="callBack()">
    <div id="res"></div>
</body>
</html>

JavaScript is a dynamic programming language and can be used for many different things. If it's not used from within the browser you can fully rely on things like multiple threads, event loops etc. You should check out node.js.

The browser unfortunately only gives you a strict set of features of the language.

Web workers

You can use Web Workers to create background threads

Web Workers provide a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface. In addition, they can perform I/O using XMLHttpRequest (although the responseXML and channel attributes are always null). Once created, a worker can send messages to the JavaScript code that created it by posting messages to an event handler specified by that code (and vice versa.) This article provides a detailed introduction to using web workers.

Browser compatibility

Chrome: 4

Firefox (Gecko): 3.5

Internet Explorer: 10.0

Opera: 10.6

Safari (WebKit): 4

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top